godot-jolt: Certain degenerate triangles in `ConcavePolygonShape3D` causes errors or hang

I have a simple scene that has a door with hinges and Jolt completely freezes on it. Stuck in some GJK stuff:

 	[Inline Frame] godot-jolt_windows-x64_editor.dll!JPH::GJKClosestPoint::GetClosestPoints(const JPH::ConvexShape::Support & inA, const JPH::TransformedConvexObject<JPH::ConvexShape::Support> & inB, float inTolerance, float inMaxDistSq, JPH::Vec3 & ioV, JPH::Vec3 & outPointA, JPH::Vec3 & outPointB) Line 373	C++
>	[Inline Frame] godot-jolt_windows-x64_editor.dll!JPH::EPAPenetrationDepth::GetPenetrationDepthStepGJK(const JPH::ConvexShape::Support & inAExcludingConvexRadius, float inConvexRadiusA, const JPH::TransformedConvexObject<JPH::ConvexShape::Support> & inBExcludingConvexRadius, float inConvexRadiusB, float inTolerance, JPH::Vec3 & ioV, JPH::Vec3 & outPointA, JPH::Vec3 & outPointB) Line 107	C++
 	godot-jolt_windows-x64_editor.dll!JPH::ConvexShape::sCollideConvexVsConvex(const JPH::Shape * inShape1, const JPH::Shape * inShape2, JPH::Vec3 inScale1, JPH::Vec3 inScale2, const JPH::Mat44 & inCenterOfMassTransform1, const JPH::Mat44 & inCenterOfMassTransform2, const JPH::SubShapeIDCreator & inSubShapeIDCreator1, const JPH::SubShapeIDCreator & inSubShapeIDCreator2, const JPH::CollideShapeSettings & inCollideShapeSettings, JPH::CollisionCollector<JPH::CollideShapeResult,JPH::CollisionCollectorTraitsCollideShape> & ioCollector, const JPH::ShapeFilter & inShapeFilter) Line 92	C++
 	[Inline Frame] godot-jolt_windows-x64_editor.dll!JPH::CollisionDispatch::sCollideShapeVsShape(const JPH::Shape * inShape1, const JPH::Shape * inShape2, JPH::Vec3 inScale1, JPH::Vec3 inScale2, const JPH::Mat44 & inCenterOfMassTransform1, const JPH::Mat44 & inCenterOfMassTransform2, const JPH::SubShapeIDCreator & inSubShapeIDCreator1, const JPH::SubShapeIDCreator & inSubShapeIDCreator2, const JPH::CollideShapeSettings & inCollideShapeSettings, JPH::CollisionCollector<JPH::CollideShapeResult,JPH::CollisionCollectorTraitsCollideShape> & ioCollector, const JPH::ShapeFilter & inShapeFilter) Line 39	C++
 	godot-jolt_windows-x64_editor.dll!`anonymous namespace'::collide_override_user_data_vs_shape(const JPH::Shape * p_shape1, const JPH::Shape * p_shape2, JPH::Vec3 p_scale1, JPH::Vec3 p_scale2, const JPH::Mat44 & p_center_of_mass_transform1, const JPH::Mat44 & p_center_of_mass_transform2, const JPH::SubShapeIDCreator & p_sub_shape_id_creator1, const JPH::SubShapeIDCreator & p_sub_shape_id_creator2, const JPH::CollideShapeSettings & p_collide_shape_settings, JPH::CollisionCollector<JPH::CollideShapeResult,JPH::CollisionCollectorTraitsCollideShape> & p_collector, const JPH::ShapeFilter & p_shape_filter) Line 26	C++
 	[Inline Frame] godot-jolt_windows-x64_editor.dll!JPH::CollisionDispatch::sCollideShapeVsShape(const JPH::Shape * inShape1, const JPH::Shape * inShape2, JPH::Vec3 inScale1, JPH::Vec3 inScale2, const JPH::Mat44 & inCenterOfMassTransform1, const JPH::Mat44 & inCenterOfMassTransform2, const JPH::SubShapeIDCreator & inSubShapeIDCreator1, const JPH::SubShapeIDCreator & inSubShapeIDCreator2, const JPH::CollideShapeSettings & inCollideShapeSettings, JPH::CollisionCollector<JPH::CollideShapeResult,JPH::CollisionCollectorTraitsCollideShape> & ioCollector, const JPH::ShapeFilter & inShapeFilter) Line 39	C++
 	godot-jolt_windows-x64_editor.dll!JPH::RotatedTranslatedShape::sCollideRotatedTranslatedVsShape(const JPH::Shape * inShape1, const JPH::Shape * inShape2, JPH::Vec3 inScale1, JPH::Vec3 inScale2, const JPH::Mat44 & inCenterOfMassTransform1, const JPH::Mat44 & inCenterOfMassTransform2, const JPH::SubShapeIDCreator & inSubShapeIDCreator1, const JPH::SubShapeIDCreator & inSubShapeIDCreator2, const JPH::CollideShapeSettings & inCollideShapeSettings, JPH::CollisionCollector<JPH::CollideShapeResult,JPH::CollisionCollectorTraitsCollideShape> & ioCollector, const JPH::ShapeFilter & inShapeFilter) Line 187	C++
 	[Inline Frame] godot-jolt_windows-x64_editor.dll!JPH::CollisionDispatch::sCollideShapeVsShape(const JPH::Shape * inShape1, const JPH::Shape * inShape2, JPH::Vec3 inScale1, JPH::Vec3 inScale2, const JPH::Mat44 & inCenterOfMassTransform1, const JPH::Mat44 & inCenterOfMassTransform2, const JPH::SubShapeIDCreator & inSubShapeIDCreator1, const JPH::SubShapeIDCreator & inSubShapeIDCreator2, const JPH::CollideShapeSettings & inCollideShapeSettings, JPH::CollisionCollector<JPH::CollideShapeResult,JPH::CollisionCollectorTraitsCollideShape> & ioCollector, const JPH::ShapeFilter & inShapeFilter) Line 39	C++
 	godot-jolt_windows-x64_editor.dll!`anonymous namespace'::collide_shape_vs_override_user_data(const JPH::Shape * p_shape1, const JPH::Shape * p_shape2, JPH::Vec3 p_scale1, JPH::Vec3 p_scale2, const JPH::Mat44 & p_center_of_mass_transform1, const JPH::Mat44 & p_center_of_mass_transform2, const JPH::SubShapeIDCreator & p_sub_shape_id_creator1, const JPH::SubShapeIDCreator & p_sub_shape_id_creator2, const JPH::CollideShapeSettings & p_collide_shape_settings, JPH::CollisionCollector<JPH::CollideShapeResult,JPH::CollisionCollectorTraitsCollideShape> & p_collector, const JPH::ShapeFilter & p_shape_filter) Line 58	C++
 	[Inline Frame] godot-jolt_windows-x64_editor.dll!JPH::CollisionDispatch::sCollideShapeVsShape(const JPH::Shape * inShape1, const JPH::Shape * inShape2, JPH::Vec3 inScale1, JPH::Vec3 inScale2, const JPH::Mat44 & inCenterOfMassTransform1, const JPH::Mat44 & inCenterOfMassTransform2, const JPH::SubShapeIDCreator & inSubShapeIDCreator1, const JPH::SubShapeIDCreator & inSubShapeIDCreator2, const JPH::CollideShapeSettings & inCollideShapeSettings, JPH::CollisionCollector<JPH::CollideShapeResult,JPH::CollisionCollectorTraitsCollideShape> & ioCollector, const JPH::ShapeFilter & inShapeFilter) Line 39	C++
 	godot-jolt_windows-x64_editor.dll!JPH::PhysicsSystem::ProcessBodyPair(JPH::ContactConstraintManager::ContactAllocator & ioContactAllocator, const JPH::BodyPair & inBodyPair) Line 1081	C++
 	godot-jolt_windows-x64_editor.dll!JPH::PhysicsSystem::JobFindCollisions(JPH::PhysicsUpdateContext::Step * ioStep, int inJobIndex) Line 908	C++
 	[Inline Frame] godot-jolt_windows-x64_editor.dll!std::_Func_class<void>::operator()() Line 874	C++
 	godot-jolt_windows-x64_editor.dll!JPH::JobSystem::Job::Execute() Line 240	C++
 	godot-jolt_windows-x64_editor.dll!JoltJobSystem::Job::execute(void * p_user_data) Line 82	C++
 	godot.windows.editor.x86_64.exe!WorkerThreadPool::_process_task(WorkerThreadPool::Task * p_task) Line 137	C++
 	[Inline Frame] godot.windows.editor.x86_64.exe!WorkerThreadPool::_process_task_queue() Line 50	C++
 	godot.windows.editor.x86_64.exe!WorkerThreadPool::_thread_function(void * p_user) Line 190	C++
 	godot.windows.editor.x86_64.exe!Thread::callback(unsigned __int64 p_caller_id, const Thread::Settings & p_settings, void(*)(void *) p_callback, void * p_userdata) Line 63	C++
 	[Inline Frame] godot.windows.editor.x86_64.exe!std::invoke(void(*)(unsigned __int64, const Thread::Settings &, void(*)(void *), void *) &&) Line 1595	C++
 	godot.windows.editor.x86_64.exe!std::thread::_Invoke<std::tuple<void (__cdecl*)(unsigned __int64,Thread::Settings const &,void (__cdecl*)(void *),void *),unsigned __int64,Thread::Settings,void (__cdecl*)(void *),void *>,0,1,2,3,4>(void * _RawVals) Line 56	C++
 	godot.windows.editor.x86_64.exe!thread_start<unsigned int (__cdecl*)(void *),1>(void * const parameter) Line 97	C++
 	kernel32.dll!BaseThreadInitThunk()	Unknown
 	ntdll.dll!RtlUserThreadStart()	Unknown

Minimal repro project attached in reply (github failed for some reason). I think this might be a Jolt bug where the door is exactly the size of the door frame and it just gets stuck trying to resolve this, maybe? Worked fine with Godot physics, though.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 19 (16 by maintainers)

Commits related to this issue

Most upvoted comments

It has been merged.

@jitspoe I just published 0.4.1-stable, which contains this fix for dealing with all types of degenerate triangles.

You might want to get rid of them from your meshes anyway, using something like Blender’s “Degenerate Dissolve” tool, but Godot Jolt should be able to deal with them now at least.

Yes, that is probably a decision I should reconsider.

I switched over in #135 to allow for using my JoltDebugGeometry3D node in distributed releases, since JPH_DEBUG_RENDERER is only defined in Debug/Release builds of Jolt. However, I haven’t really advertised this node anywhere (besides having it disabled in my example scenes) because I wasn’t really happy with how you make use of it, so it’s mostly ended up being a development tool for myself.

The long-term plan was to instead implement it as some sort of gizmo or draw mode using editor plugins (which has only just recently been made available for extensions), but ideally Godot’s own editor gizmos and (somewhat lackluster) debug rendering should line up 1:1 with Jolt, meaning there shouldn’t be any need to have this be a public-facing thing in the first place, which means I could just use Jolt’s Distribution builds in my EditorDistribution builds.

In either case, non-editor Distribution builds of Godot Jolt use proper Distribution builds of Jolt, and are what gets used in the final release export of a Godot application, so there you’ll get the fully optimized thing.