Replies: 4 comments 14 replies
-
I think it is certainly possible to implement this. You could probably implement this using a new The biggest issue with it that I see (which you already mention) is in multi threaded scenarios. If there are 2 threads doing a query on the same shape at the same time, you'll need a mutex lock to ensure that only 1 thread does the rebuild. For godot physics this is probably not an issue since everything is serialized through a physics thread anyway (which I don't think you support for godot-jolt yet). As for the question if this should be included in Jolt or not: It could be, but it does go a little bit against the philosophy of being able to collect lots of |
Beta Was this translation helpful? Give feedback.
-
I've spent some time exploring this idea now, and unfortunately it didn't really turn out as well as I had initially hoped. The stuff that tripped me up was:
There were probably more concerns that I've forgotten already, but assuming I haven't completely misunderstood something here, then I'm not sure that this was a great fit for how I chose to incorporate compound shapes into Godot. If any of this sounds off, or if you have some ideas for how to work around these concerns, I'd love to hear it. I came up with a compromise in the meantime, which at least makes a slight dent in the problem here: godotengine/godot#101189 |
Beta Was this translation helpful? Give feedback.
-
I've integrated the shape in the I see that a call to I'm wondering now if this implementation has enough use cases to make this into an officially supported shape. |
Beta Was this translation helpful? Give feedback.
-
Oh, I just spotted: the shape type should not be JPH::EShapeType::Compound but UserX to prevent someone from casting the shape to CompoundShape. |
Beta Was this translation helpful? Give feedback.
-
I've been noodling over this idea for a while now, and figured I would sit down at some point to actually explore it properly, but haven't really found the time. So instead I thought I would just go ahead and ask you about it, to see if it's even worth exploring.
In short, would it be possible to somehow have a sort of hybrid/deferred
StaticCompoundShape
that behaves as aMutableCompoundShape
until you explicitly invoke someOptimize()
method on it, which then builds/rebuilds all the spatial partitioning and whatnot?I feel like something along those lines would provide the best of both worlds for the most part. Instead of having to rebuild the whole
StaticCompoundShape
on any sub-shape mutation/transformation, or going the alternative route of deferring the rebuild of it to some later point, which would presumably necessitate rebuilding all of them on any physics query, you would instead just defer the optimization of the compound shape to some later point, with a performance hit on any physics query performed on it until that optimization happens.I understand that would come with the same caveats as
MutableCompoundShape
with regards to race conditions, and needing to invokeBodyInterface::NotifyShapeChanged
and whatever else, but those seem like small concessions.Anyway, I'm not asking for this to be added to Jolt necessarily, since it could almost certainly be done user-side, but I figured I would pick your brain about it anyway.
Beta Was this translation helpful? Give feedback.
All reactions