Compound Shapes JBullet

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
Hi everyone! I have problem with the "Compound Shape". I changed the method "BulletPhysics.getShapeFor" by adding compoundShape in it. And I added the "offset" value in the RigidBodyComponent (I did it for the shift of the center of mass ) But, when I start the Terasology and create the entity with the compound shape, the entity will falls down to ignoring the collision with the world =(
Here is the method code:

Code:
    private CollisionShape getShapeFor(EntityRef entity) {
        BoxShapeComponent box = entity.getComponent(BoxShapeComponent.class);
        RigidBodyComponent rb = entity.getComponent(RigidBodyComponent.class);
        ConvexShape shape = null;
 
        if (box != null) {
            Vector3f halfExtents = new Vector3f(box.extents);
            halfExtents.scale(0.5f);
            shape = new BoxShape(halfExtents);
        }
        SphereShapeComponent sphere = entity.getComponent(SphereShapeComponent.class);
        if (sphere != null) {
            shape = new SphereShape(sphere.radius);
        }
        CapsuleShapeComponent capsule = entity.getComponent(CapsuleShapeComponent.class);
        if (capsule != null) {
            shape = new CapsuleShape(capsule.radius, capsule.height);
        }
        CylinderShapeComponent cylinder = entity.getComponent(CylinderShapeComponent.class);
        if (cylinder != null) {
            shape = new CylinderShape(new Vector3f(cylinder.radius, 0.5f * cylinder.height, cylinder.radius));
        }
        HullShapeComponent hull = entity.getComponent(HullShapeComponent.class);
        if (hull != null) {
            ObjectArrayList<Vector3f> verts = new ObjectArrayList<Vector3f>();
            TFloatIterator iterator = hull.sourceMesh.getVertices().iterator();
            while (iterator.hasNext()) {
                Vector3f newVert = new Vector3f();
                newVert.x = iterator.next();
                newVert.y = iterator.next();
                newVert.z = iterator.next();
                verts.add(newVert);
            }
            shape = new ConvexHullShape(verts);
        }
 
        if ( rb != null && rb.offset != null && rb.offset.length() > 0 ){
            CompoundShape compoundShape = new CompoundShape();
            Transform localTransform = new Transform();
            localTransform.setIdentity();
            localTransform.origin.set(rb.offset);
            compoundShape.addChildShape(localTransform, shape);
            return compoundShape;
        }
 
        if ( shape != null ){
            return shape;
        }
 
        CharacterMovementComponent characterMovementComponent = entity.getComponent(CharacterMovementComponent.class);
        if (characterMovementComponent != null) {
            return new CapsuleShape(characterMovementComponent.radius, characterMovementComponent.height);
        }
        logger.error("Creating physics object that requires a ShapeComponent or CharacterMovementComponent, but has neither. Entity: {}", entity);
        throw new IllegalArgumentException("Creating physics object that requires a ShapeComponent or CharacterMovementComponent, but has neither. Entity: " + entity);
    }
Can anybody help me? =(
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Well, I guess test it against something other than the world (like some kinematic rigid bodies).
 

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
Huh! I see a new strangeness - If I drop a block and create a minecart above it, then the minecart will bounce off the dropped blocks and fall down ignoring the collision with the world.:rainbowhuh:
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Iit is entirely possible I never added support for compound shape <-> voxel world collisions to TeraBullet. Or that it has never worked, since it was never tested.
 

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
Immortius, In that case, can you add a support the collision between a compound shape and voxel world? Pleeeeeease, please, please please:omg:
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Fixed a bug in tera-bullet, and compound shapes were colliding with the world when I tested, so try now?
 

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
The collision still does not work for the compound shapes.
I pulled from develop branch and console show me that:

.../org/terasology/engine/TerasologyEngine.java | 5 +
.../org/terasology/engine/internal/TimeBase.java | 2 +-
.../modes/loadProcesses/InitialiseSystems.java | 3 +-
.../modes/loadProcesses/PostBeginSystems.java | 2 +-
.../modes/loadProcesses/PreBeginSystems.java | 2 +-
.../engine/subsystem/lwjgl/LwjglInput.java | 8 +-
.../java/org/terasology/input/InputSystem.java | 4 +-
.../org/terasology/input/device/InputAction.java | 24 ++-
.../terasology/input/internal/BindCommands.java | 18 +--
.../terasology/input/lwjgl/LwjglMouseDevice.java | 4 +-
.../logic/inventory/ItemDifferentiating.java | 15 ++
.../logic/players/FirstPersonRenderer.java | 7 +-
.../rendering/VertexBufferObjectUtil.java | 4 -
.../terasology/rendering/assets/font/FontImpl.java | 1 -
.../terasology/rendering/nui/ControlWidget.java | 2 +
.../terasology/rendering/nui/CoreScreenLayer.java | 4 +
.../terasology/rendering/nui/asset/UILoader.java | 4 +-
.../rendering/nui/internal/NUIManagerInternal.java | 13 +-
.../rendering/nui/layers/hud/CoreHudWidget.java | 9 +-
.../rendering/nui/layers/hud/HUDScreenLayer.java | 16 +-
.../nui/layers/ingame/inventory/InventoryCell.java | 2 +-
.../ingame/inventory/TransferItemCursor.java | 4 +
.../nui/layers/mainMenu/SelectModulesScreen.java | 22 +--
.../inputSettings/InputSettingsScreen.java | 6 +-
.../videoSettings/VideoSettingsScreen.java | 8 +-
.../rendering/nui/layouts/ColumnLayout.java | 1 +
.../rendering/nui/layouts/MultiRowLayout.java | 3 +-
.../world/block/loader/WorldAtlasImpl.java | 35 ++++
.../main/resources/assets/shapes/halfSlope.shape | 171 ++++++++++++++------
Which files you have changed? Maybe you did not push the new changes? =(
 

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
Maybe I'm not good sleep. I was looking a terra-bullet in the repository of Terasologyo_O
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
develop for terasology has been changed to depend on version 1.0.2 of tera-bullet. This will require recreating the workspace to use.
 

Adeon

terasology.ru
Contributor
Architecture
GUI
Logistics
Wooohhooo!!!! Immortius you are genius! It's works!! =)
But... when I execute this code in my module:

Code:
Camera playerCamera = CoreRegistry.get(WorldRenderer.class).getActiveCamera();

Iget error:
22:05:38.238 [main] ERROR o.t.engine.module.ModuleClassLoader - Denied access to class (not available to modules): org.terasology.rendering.world.WorldRenderer
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Correct, you are not allowed to use the WorldRenderer, and I'm not going to give access to it. Additionally, I don't want to give access to Camera, as it needs to be replaced with an entity based approach (CameraComponent). What are you attempting to achieve?
 
Top