|
@@ -569,7 +569,7 @@ SamplesApp::SamplesApp()
|
|
#endif // JPH_DEBUG_RENDERER
|
|
#endif // JPH_DEBUG_RENDERER
|
|
mDebugUI->CreateTextButton(main_menu, "Mouse Probe", [this]() {
|
|
mDebugUI->CreateTextButton(main_menu, "Mouse Probe", [this]() {
|
|
UIElement *probe_options = mDebugUI->CreateMenu();
|
|
UIElement *probe_options = mDebugUI->CreateMenu();
|
|
- mDebugUI->CreateComboBox(probe_options, "Mode", { "Pick", "Ray", "RayCollector", "CollidePoint", "CollideShape", "CastShape", "CollideSoftBody", "TransfShape", "GetTriangles", "BP Ray", "BP Box", "BP Sphere", "BP Point", "BP OBox", "BP Cast Box" }, (int)mProbeMode, [this](int inItem) { mProbeMode = (EProbeMode)inItem; });
|
|
|
|
|
|
+ mDebugUI->CreateComboBox(probe_options, "Mode", { "Pick", "Ray", "RayCollector", "CollidePoint", "CollideShape", "CollideShapeEdgRem", "CastShape", "CollideSoftBody", "TransfShape", "GetTriangles", "BP Ray", "BP Box", "BP Sphere", "BP Point", "BP OBox", "BP Cast Box" }, (int)mProbeMode, [this](int inItem) { mProbeMode = (EProbeMode)inItem; });
|
|
mDebugUI->CreateComboBox(probe_options, "Shape", { "Sphere", "Box", "ConvexHull", "Capsule", "TaperedCapsule", "Cylinder", "Triangle", "RotatedTranslated", "StaticCompound", "StaticCompound2", "MutableCompound", "Mesh" }, (int)mProbeShape, [this](int inItem) { mProbeShape = (EProbeShape)inItem; });
|
|
mDebugUI->CreateComboBox(probe_options, "Shape", { "Sphere", "Box", "ConvexHull", "Capsule", "TaperedCapsule", "Cylinder", "Triangle", "RotatedTranslated", "StaticCompound", "StaticCompound2", "MutableCompound", "Mesh" }, (int)mProbeShape, [this](int inItem) { mProbeShape = (EProbeShape)inItem; });
|
|
mDebugUI->CreateCheckBox(probe_options, "Scale Shape", mScaleShape, [this](UICheckBox::EState inState) { mScaleShape = inState == UICheckBox::STATE_CHECKED; });
|
|
mDebugUI->CreateCheckBox(probe_options, "Scale Shape", mScaleShape, [this](UICheckBox::EState inState) { mScaleShape = inState == UICheckBox::STATE_CHECKED; });
|
|
mDebugUI->CreateSlider(probe_options, "Scale X", mShapeScale.GetX(), -5.0f, 5.0f, 0.1f, [this](float inValue) { mShapeScale.SetX(inValue); });
|
|
mDebugUI->CreateSlider(probe_options, "Scale X", mShapeScale.GetX(), -5.0f, 5.0f, 0.1f, [this](float inValue) { mShapeScale.SetX(inValue); });
|
|
@@ -1267,6 +1267,7 @@ bool SamplesApp::CastProbe(float inProbeLength, float &outFraction, RVec3 &outPo
|
|
break;
|
|
break;
|
|
|
|
|
|
case EProbeMode::CollideShape:
|
|
case EProbeMode::CollideShape:
|
|
|
|
+ case EProbeMode::CollideShapeWithInternalEdgeRemoval:
|
|
{
|
|
{
|
|
// Create shape cast
|
|
// Create shape cast
|
|
RefConst<Shape> shape = CreateProbeShape();
|
|
RefConst<Shape> shape = CreateProbeShape();
|
|
@@ -1281,25 +1282,28 @@ bool SamplesApp::CastProbe(float inProbeLength, float &outFraction, RVec3 &outPo
|
|
settings.mCollectFacesMode = mCollectFacesMode;
|
|
settings.mCollectFacesMode = mCollectFacesMode;
|
|
settings.mMaxSeparationDistance = mMaxSeparationDistance;
|
|
settings.mMaxSeparationDistance = mMaxSeparationDistance;
|
|
|
|
|
|
|
|
+ // Select the right function
|
|
|
|
+ auto collide_shape_function = mProbeMode == EProbeMode::CollideShape? &NarrowPhaseQuery::CollideShape : &NarrowPhaseQuery::CollideShapeWithInternalEdgeRemoval;
|
|
|
|
+
|
|
Array<CollideShapeResult> hits;
|
|
Array<CollideShapeResult> hits;
|
|
if (mMaxHits == 0)
|
|
if (mMaxHits == 0)
|
|
{
|
|
{
|
|
AnyHitCollisionCollector<CollideShapeCollector> collector;
|
|
AnyHitCollisionCollector<CollideShapeCollector> collector;
|
|
- mPhysicsSystem->GetNarrowPhaseQuery().CollideShape(shape, Vec3::sReplicate(1.0f), shape_transform, settings, base_offset, collector);
|
|
|
|
|
|
+ (mPhysicsSystem->GetNarrowPhaseQuery().*collide_shape_function)(shape, Vec3::sReplicate(1.0f), shape_transform, settings, base_offset, collector, { }, { }, { }, { });
|
|
if (collector.HadHit())
|
|
if (collector.HadHit())
|
|
hits.push_back(collector.mHit);
|
|
hits.push_back(collector.mHit);
|
|
}
|
|
}
|
|
else if (mMaxHits == 1)
|
|
else if (mMaxHits == 1)
|
|
{
|
|
{
|
|
ClosestHitCollisionCollector<CollideShapeCollector> collector;
|
|
ClosestHitCollisionCollector<CollideShapeCollector> collector;
|
|
- mPhysicsSystem->GetNarrowPhaseQuery().CollideShape(shape, Vec3::sReplicate(1.0f), shape_transform, settings, base_offset, collector);
|
|
|
|
|
|
+ (mPhysicsSystem->GetNarrowPhaseQuery().*collide_shape_function)(shape, Vec3::sReplicate(1.0f), shape_transform, settings, base_offset, collector, { }, { }, { }, { });
|
|
if (collector.HadHit())
|
|
if (collector.HadHit())
|
|
hits.push_back(collector.mHit);
|
|
hits.push_back(collector.mHit);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
AllHitCollisionCollector<CollideShapeCollector> collector;
|
|
AllHitCollisionCollector<CollideShapeCollector> collector;
|
|
- mPhysicsSystem->GetNarrowPhaseQuery().CollideShape(shape, Vec3::sReplicate(1.0f), shape_transform, settings, base_offset, collector);
|
|
|
|
|
|
+ (mPhysicsSystem->GetNarrowPhaseQuery().*collide_shape_function)(shape, Vec3::sReplicate(1.0f), shape_transform, settings, base_offset, collector, { }, { }, { }, { });
|
|
collector.Sort();
|
|
collector.Sort();
|
|
hits.insert(hits.end(), collector.mHits.begin(), collector.mHits.end());
|
|
hits.insert(hits.end(), collector.mHits.begin(), collector.mHits.end());
|
|
if ((int)hits.size() > mMaxHits)
|
|
if ((int)hits.size() > mMaxHits)
|