0 votes

Hi,

so I'm currently playing around with voxels a littble bit and with that, dynamicly create the shapes for each voxel that is in a chunk. The collision etc. works just fine, but actually it wouldn't make much sense to have these collisionshape always activated, so is there a nice way to disable them to save some performance? I also notice that the collisionshape that I'm generating never get displayed in the game view if I enable the option "Visible Collision Shape" in the editor. Only shapes that was created in the editor will be shown. Is this intended?

in Engine by (186 points)

How are you creating the collision shapes? Are you instancing CollisionShape nodes? If you do, keep in mind these are not intented to be created by the game, they are editor helpers.
Now, about seeing them... I have no idea why they don't show :/

This is how I create the collision shape:

enter image description here

Maybe they don't show up in the game, because I don't use the editor helper class, because this class manage this behavior?

Oh and by the way, is there a way to manipulate a mesh? The only thing I found so far was the "meshDataTool" but this only allows to manipulate vertices and not to remove them, this is the same case for the "surfaceTool". Is there no class/helper to actually remove unwatend vertices?

I use SurfaceTool to create a mesh, I don't know of other ways. But I'm looking forward to discover better ways because SurfaceTool is not as efficient as it could be, I made a voxel prototype like you and I basically rebuild chunks everytime at least one voxel changed in it. It's not a problem, but the meshing process is too slow and could be greatly improved with a more direct access to how geometry is built.

I still have no idea about previewing 3D collision shapes, never played with them so far :/

Yeah that was exactly my aproach too, but now I've switched it in that way, that a chunks gets splittet into submeshes which contains 64 voxels. With this approach removing voxel goes quite fast, since I only need to renew a small part of the chunk/mesh and with threading it's not even noticeable that the pc takes some time to regenerate it.

Now back to topic ^^ is there a way to disable collision shapes for a while or do I need to dynamicly remove and add them, if an entity comes near it?

If disabling is not an option, I would remove them from all physics layers (making them effectivelly colliding with nothing) and pool them in a list. Then when I need an active collider, I would pick one from the pool and set it on the appropriate position and collision layers. It should be efficient because there will be minimal memory allocations. However I never tried this approach with voxels, I usually implemented my own collider specialized for voxel grids. Thought doing it in GDScript would be too slow :p

Sorry for the late reply, it actually seems like there is no real way to disabling a created collision shape, at least I didn't found one. So your idear seems like the best solution for this.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.