Now returns object physics layer in shape cast result
This commit is contained in:
@@ -233,6 +233,7 @@ namespace Nuake
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
BPLayerInterfaceImpl JoltBroadphaseLayerInterface = BPLayerInterfaceImpl();
|
BPLayerInterfaceImpl JoltBroadphaseLayerInterface = BPLayerInterfaceImpl();
|
||||||
@@ -522,6 +523,8 @@ namespace Nuake
|
|||||||
|
|
||||||
JPH::ShapeCastSettings shapeCastSetting;
|
JPH::ShapeCastSettings shapeCastSetting;
|
||||||
shapeCastSetting.mCollectFacesMode = JPH::ECollectFacesMode::CollectFaces;
|
shapeCastSetting.mCollectFacesMode = JPH::ECollectFacesMode::CollectFaces;
|
||||||
|
shapeCastSetting.mUseShrunkenShapeAndConvexRadius = true;
|
||||||
|
|
||||||
_JoltPhysicsSystem->GetNarrowPhaseQuery().CastShape(ray, shapeCastSetting, JPH::Vec3(0, 0, 0), collector);
|
_JoltPhysicsSystem->GetNarrowPhaseQuery().CastShape(ray, shapeCastSetting, JPH::Vec3(0, 0, 0), collector);
|
||||||
|
|
||||||
std::vector<ShapeCastResult> shapecastResults;
|
std::vector<ShapeCastResult> shapecastResults;
|
||||||
@@ -538,14 +541,16 @@ namespace Nuake
|
|||||||
|
|
||||||
auto bodyId = static_cast<JPH::BodyID>(results[i].mBodyID2);
|
auto bodyId = static_cast<JPH::BodyID>(results[i].mBodyID2);
|
||||||
JPH::TransformedShape ts = _JoltPhysicsSystem->GetBodyInterface().GetTransformedShape(results[i].mBodyID2);
|
JPH::TransformedShape ts = _JoltPhysicsSystem->GetBodyInterface().GetTransformedShape(results[i].mBodyID2);
|
||||||
|
|
||||||
JPH::Vec3 surfaceNormal = ts.GetWorldSpaceSurfaceNormal(results[i].mSubShapeID2, results[i].mContactPointOn2);
|
JPH::Vec3 surfaceNormal = ts.GetWorldSpaceSurfaceNormal(results[i].mSubShapeID2, results[i].mContactPointOn2);
|
||||||
|
|
||||||
|
auto layer = _JoltBodyInterface->GetObjectLayer(bodyId);
|
||||||
|
|
||||||
ShapeCastResult result
|
ShapeCastResult result
|
||||||
{
|
{
|
||||||
Vector3(hitPosition.GetX(), hitPosition.GetY(), hitPosition.GetZ()),
|
Vector3(hitPosition.GetX(), hitPosition.GetY(), hitPosition.GetZ()),
|
||||||
hitFraction,
|
hitFraction,
|
||||||
Vector3(surfaceNormal.GetX(), surfaceNormal.GetY(), surfaceNormal.GetZ())
|
Vector3(surfaceNormal.GetX(), surfaceNormal.GetY(), surfaceNormal.GetZ()),
|
||||||
|
layer
|
||||||
};
|
};
|
||||||
|
|
||||||
shapecastResults.push_back(std::move(result));
|
shapecastResults.push_back(std::move(result));
|
||||||
|
|||||||
@@ -17,5 +17,6 @@ namespace Nuake
|
|||||||
Vector3 ImpactPosition;
|
Vector3 ImpactPosition;
|
||||||
float Fraction;
|
float Fraction;
|
||||||
Vector3 ImpactNormal;
|
Vector3 ImpactNormal;
|
||||||
|
float Layer;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ namespace Nuake {
|
|||||||
results.push_back(hit.ImpactNormal.y);
|
results.push_back(hit.ImpactNormal.y);
|
||||||
results.push_back(hit.ImpactNormal.z);
|
results.push_back(hit.ImpactNormal.z);
|
||||||
results.push_back(hit.Fraction);
|
results.push_back(hit.Fraction);
|
||||||
|
results.push_back(hit.Layer);
|
||||||
|
|
||||||
}
|
}
|
||||||
return Coral::Array<float>::New(results);
|
return Coral::Array<float>::New(results);
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ namespace Nuake.Net
|
|||||||
public Vector3 ImpactPosition;
|
public Vector3 ImpactPosition;
|
||||||
public Vector3 ImpactNormal;
|
public Vector3 ImpactNormal;
|
||||||
public float Fraction;
|
public float Fraction;
|
||||||
|
public Layers Layer;
|
||||||
}
|
}
|
||||||
public struct BoxInternal
|
public struct BoxInternal
|
||||||
{
|
{
|
||||||
@@ -106,6 +107,16 @@ namespace Nuake.Net
|
|||||||
public float Height;
|
public float Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Layers
|
||||||
|
{
|
||||||
|
NON_MOVING = 0,
|
||||||
|
MOVING = 1,
|
||||||
|
KINEMATIC = 2,
|
||||||
|
CHARACTER_GHOST = 3,
|
||||||
|
CHARACTER = 4,
|
||||||
|
SENSORS = 5
|
||||||
|
}
|
||||||
|
|
||||||
internal static unsafe delegate*<float, float, float, float, float, float, BoxInternal, NativeArray<float>> ShapeCastBoxIcall;
|
internal static unsafe delegate*<float, float, float, float, float, float, BoxInternal, NativeArray<float>> ShapeCastBoxIcall;
|
||||||
internal static unsafe delegate*<float, float, float, float, float, float, float, NativeArray<float>> ShapeCastSphereIcall;
|
internal static unsafe delegate*<float, float, float, float, float, float, float, NativeArray<float>> ShapeCastSphereIcall;
|
||||||
internal static unsafe delegate*<float, float, float, float, float, float, CapsuleInternal, NativeArray<float>> ShapeCastCapsuleIcall;
|
internal static unsafe delegate*<float, float, float, float, float, float, CapsuleInternal, NativeArray<float>> ShapeCastCapsuleIcall;
|
||||||
@@ -125,7 +136,6 @@ namespace Nuake.Net
|
|||||||
{
|
{
|
||||||
NativeArray<float> resultICall = ShapeCastBoxIcall(from.X, from.Y, from.Z, to.X, to.Y, to.Z, boxInternal);
|
NativeArray<float> resultICall = ShapeCastBoxIcall(from.X, from.Y, from.Z, to.X, to.Y, to.Z, boxInternal);
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < resultICall.Length / 7; i++)
|
for (int i = 0; i < resultICall.Length / 7; i++)
|
||||||
{
|
{
|
||||||
int index = i * 7;
|
int index = i * 7;
|
||||||
@@ -133,7 +143,8 @@ namespace Nuake.Net
|
|||||||
{
|
{
|
||||||
ImpactPosition = new Vector3(resultICall[index + 0], resultICall[index + 1], resultICall[index + 2]),
|
ImpactPosition = new Vector3(resultICall[index + 0], resultICall[index + 1], resultICall[index + 2]),
|
||||||
ImpactNormal = new Vector3(resultICall[index + 3], resultICall[index + 4], resultICall[index + 5]),
|
ImpactNormal = new Vector3(resultICall[index + 3], resultICall[index + 4], resultICall[index + 5]),
|
||||||
Fraction = resultICall[index + 6]
|
Fraction = resultICall[index + 6],
|
||||||
|
Layer = (Layers)resultICall[index + 7]
|
||||||
};
|
};
|
||||||
|
|
||||||
result.Add(shapeCastResult);
|
result.Add(shapeCastResult);
|
||||||
@@ -158,7 +169,8 @@ namespace Nuake.Net
|
|||||||
{
|
{
|
||||||
ImpactPosition = new Vector3(resultICall[index + 0], resultICall[index + 1], resultICall[index + 2]),
|
ImpactPosition = new Vector3(resultICall[index + 0], resultICall[index + 1], resultICall[index + 2]),
|
||||||
ImpactNormal = new Vector3(resultICall[index + 3], resultICall[index + 4], resultICall[index + 5]),
|
ImpactNormal = new Vector3(resultICall[index + 3], resultICall[index + 4], resultICall[index + 5]),
|
||||||
Fraction = resultICall[index + 6]
|
Fraction = resultICall[index + 6],
|
||||||
|
Layer = (Layers)resultICall[index + 7]
|
||||||
};
|
};
|
||||||
|
|
||||||
result.Add(shapeCastResult);
|
result.Add(shapeCastResult);
|
||||||
@@ -189,7 +201,8 @@ namespace Nuake.Net
|
|||||||
{
|
{
|
||||||
ImpactPosition = new Vector3(resultICall[index + 0], resultICall[index + 1], resultICall[index + 2]),
|
ImpactPosition = new Vector3(resultICall[index + 0], resultICall[index + 1], resultICall[index + 2]),
|
||||||
ImpactNormal = new Vector3(resultICall[index + 3], resultICall[index + 4], resultICall[index + 5]),
|
ImpactNormal = new Vector3(resultICall[index + 3], resultICall[index + 4], resultICall[index + 5]),
|
||||||
Fraction = resultICall[index + 6]
|
Fraction = resultICall[index + 6],
|
||||||
|
Layer = (Layers)resultICall[index + 7]
|
||||||
};
|
};
|
||||||
|
|
||||||
result.Add(shapeCastResult);
|
result.Add(shapeCastResult);
|
||||||
@@ -220,7 +233,8 @@ namespace Nuake.Net
|
|||||||
{
|
{
|
||||||
ImpactPosition = new Vector3(resultICall[index + 0], resultICall[index + 1], resultICall[index + 2]),
|
ImpactPosition = new Vector3(resultICall[index + 0], resultICall[index + 1], resultICall[index + 2]),
|
||||||
ImpactNormal = new Vector3(resultICall[index + 3], resultICall[index + 4], resultICall[index + 5]),
|
ImpactNormal = new Vector3(resultICall[index + 3], resultICall[index + 4], resultICall[index + 5]),
|
||||||
Fraction = resultICall[index + 6]
|
Fraction = resultICall[index + 6],
|
||||||
|
Layer = (Layers)resultICall[index + 7]
|
||||||
};
|
};
|
||||||
|
|
||||||
result.Add(shapeCastResult);
|
result.Add(shapeCastResult);
|
||||||
|
|||||||
Reference in New Issue
Block a user