Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offsets and sizing of shapes / Compound colliders #2

Open
Shinmera opened this issue Nov 9, 2023 · 5 comments
Open

Offsets and sizing of shapes / Compound colliders #2

Shinmera opened this issue Nov 9, 2023 · 5 comments

Comments

@Shinmera
Copy link

Shinmera commented Nov 9, 2023

So it seems that Blender does not allow one to set a custom size or offset for the physics shapes, which makes them completely useless if your object origin doesn't also happen to align with the centre of your intended physics shape, or if the intended bound of the shape should not just match the geometry.

Any ideas on how to tackle this problem?

@eoineoineoin
Copy link
Owner

Yeah, I wish Blender had more explicit control over the shapes but you can supply a proxy geometry:

  1. Change the shape type of your visual mesh to be "Compound Parent"
  2. Add a child mesh, with the appropriate shape type and modify it's transform/vertices to match the desired shape

Then, to export, the glTF exporter's "Limit to Renderable Objects" option doesn't have a way to exclude the mesh, but still include extension data (this is a limitation I'd like to fix,) so I've just been assigning an "invisible" material to those proxy meshes. Maybe as a temporary workaround, I could add a "this mesh is physics-only" to the Blender Physics panel?

@Shinmera
Copy link
Author

Shinmera commented Nov 13, 2023

Ah, that's clever. I didn't think of the compound parent method so I was lost on how to add the rigid body properties to the parent but the shape only on the child.

I think having a separate entry in the physics properties that you can enable a "Collider" instead of "Rigid Body" would be ideal, though I understand that's probably a lot more work to implement.

@Shinmera
Copy link
Author

I've noticed that when importing a glTF file where a node has a mesh, a rigidbody and a bunch of child nodes with a collider, the imported scene in Blender contains objects for each of the child nodes, but none of those objects have the rigidbody constraint applied, I suppose because they don't have a mesh of their own and Blender won't let us set it in that case?

Do you have any plans to deal with this or is there some existing workaround?

@Shinmera Shinmera changed the title Offsets and sizing of shapes Offsets and sizing of shapes / Compound colliders Nov 21, 2023
@eoineoineoin
Copy link
Owner

That sounds like a bug for sure. I try to convert to the Blender representation when importing, but it's entirely possible I've missed something. Just so I can reproduce it, you've got something like:

nodes = [
    {
         "name": "Parent",
         "children": [1],
         "mesh": 0
    },
    {
         "name": "Child",
         "extensions": { *** rigid body with a -say- box shape  **** }
    }

And the "Child" node doesn't have any physics info?

@Shinmera
Copy link
Author

Yes, the child doesn't have a mesh, so in blender it's a basic node, which can't have a rigidbody constraint. It doesn't even appear in the menu. Here's the file I was looking at:

a.zip

I can't share a screenshot right now since blender broke on my system with the update to 4.0.1 (sigh).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants