Moguri / panda3d-gltf

glTF utilities for Panda3D
BSD 3-Clause "New" or "Revised" License
82 stars 19 forks source link

Blender passive rigid bodies generate no Bullet physics nodes. #93

Closed Clockwork-Muse closed 3 years ago

Clockwork-Muse commented 3 years ago

When gltf files are imported or converted into .bam files, or files are auto-converted by the blend loader, and use Bullet physics, there are no Bullet physics nodes generated for Blender passive rigid bodies. Instead an empty node of some sort is generated:

class MyApp(ShowBase):
    def __init__(self):
        super().__init__(self)
        self.world = BulletWorld()

        self.model = self.loader.loadModel("repro.blend.bam")
        self.model.reparentTo(self.render)
        physics_node = self.model.find("**/+BulletBodyNode")
        if physics_node:
            print(physics_node.node())
        else:
            print(None)

        self.render.ls()

        query_node = self.model.children[0].children[1]
        print(query_node.node())

Outputs:

None
PandaNode render S:(CullFaceAttrib RescaleNormalAttrib)
  ModelRoot Scene
    PandaNode Cube
      GeomNode Cube (1 geoms: S:(CullFaceAttrib MaterialAttrib TextureAttrib))
      PandaNode Cube
PandaNode Cube

exporting the file with builtin physics does generate the anticipated (currently intangible) CollisionBodyNode, so presumably the gltf file itself is fine:

None
PandaNode render S:(CullFaceAttrib RescaleNormalAttrib)
  ModelRoot Scene
    PandaNode Cube
      GeomNode Cube (1 geoms: S:(CullFaceAttrib MaterialAttrib TextureAttrib))
      CollisionNode Cube (1 solids) (hidden)
CollisionNode Cube (1 solids) (hidden)

(I wish there was an easy way to observe the intermediate file)

Moguri commented 3 years ago

A BulletGhostNode is getting created as expected, but it looks like BulletGhostNode does not implement BAM serialization. In other words, this is an issue in Panda, and I am not sure if there is an appropriate work around we can implement in this library.

Clockwork-Muse commented 3 years ago

.... good to know...

rdb commented 3 years ago

Actually, passive rigid bodies should not be exported as BulletGhostNode, but rather as a BulletRigidBodyNode with zero mass. In Blender, "passive" means that the body is not affected by forces, but it does participate in collision detection.

Clockwork-Muse commented 3 years ago

@rdb - I would prefer that too (and should be static on top of that), but there's other issues to track that particular question. The exporter just currently exports all passive bodies as "intangible".

Clockwork-Muse commented 3 years ago

Fixed in panda3d/panda3d#1104