Search in sources :

Example 1 with BulletConvexHullShape

use of org.terasology.engine.physics.bullet.shapes.BulletConvexHullShape in project Terasology by MovingBlocks.

the class BlockShapeTest method testConvexHull.

@Test
public void testConvexHull() {
    BlockShape blockShape = assetManager.getAsset("engine:halfSlope", BlockShape.class).get();
    CollisionShape shape = blockShape.getCollisionShape(Rotation.rotate(Yaw.CLOCKWISE_90));
    assertTrue(shape instanceof ConvexHullShape);
    Vector3f[] test = new Vector3f[] { new Vector3f(0.49999997f, 0.0f, 0.49999997f), new Vector3f(-0.49999997f, -0.49999997f, 0.49999997f), new Vector3f(0.49999997f, -0.49999997f, 0.49999997f), new Vector3f(0.49999997f, 0.0f, -0.49999997f), new Vector3f(0.49999997f, -0.49999997f, -0.49999997f), new Vector3f(-0.49999997f, -0.49999997f, -0.49999997f), new Vector3f(0.49999997f, -0.49999997f, 0.49999997f), new Vector3f(0.49999997f, -0.49999997f, -0.49999997f), new Vector3f(0.49999997f, 0.0f, -0.49999997f), new Vector3f(0.49999997f, 0.0f, 0.49999997f), new Vector3f(0.49999997f, -0.49999997f, 0.49999997f), new Vector3f(-0.49999997f, -0.49999997f, 0.49999997f), new Vector3f(-0.49999997f, -0.49999997f, -0.49999997f), new Vector3f(0.49999997f, -0.49999997f, -0.49999997f), new Vector3f(0.49999997f, 0.0f, -0.49999997f), new Vector3f(-0.49999997f, -0.49999997f, -0.49999997f), new Vector3f(-0.49999997f, -0.49999997f, 0.49999997f), new Vector3f(0.49999997f, 0.0f, 0.49999997f) };
    BulletConvexHullShape bulletConvexHullShape = (BulletConvexHullShape) shape;
    // TODO: Test fails because native library is not loaded
    for (int x = 0; x < ((btConvexHullShape) bulletConvexHullShape.underlyingShape).getNumPoints(); x++) {
        fuzzVectorTest(test[x], ((btConvexHullShape) bulletConvexHullShape.underlyingShape).getScaledPoint(x));
    }
}
Also used : CollisionShape(org.terasology.engine.physics.shapes.CollisionShape) BlockShape(org.terasology.engine.world.block.shapes.BlockShape) Vector3f(org.joml.Vector3f) ConvexHullShape(org.terasology.engine.physics.shapes.ConvexHullShape) com.badlogic.gdx.physics.bullet.collision.btConvexHullShape(com.badlogic.gdx.physics.bullet.collision.btConvexHullShape) BulletConvexHullShape(org.terasology.engine.physics.bullet.shapes.BulletConvexHullShape) BulletConvexHullShape(org.terasology.engine.physics.bullet.shapes.BulletConvexHullShape) Test(org.junit.jupiter.api.Test)

Aggregations

com.badlogic.gdx.physics.bullet.collision.btConvexHullShape (com.badlogic.gdx.physics.bullet.collision.btConvexHullShape)1 Vector3f (org.joml.Vector3f)1 Test (org.junit.jupiter.api.Test)1 BulletConvexHullShape (org.terasology.engine.physics.bullet.shapes.BulletConvexHullShape)1 CollisionShape (org.terasology.engine.physics.shapes.CollisionShape)1 ConvexHullShape (org.terasology.engine.physics.shapes.ConvexHullShape)1 BlockShape (org.terasology.engine.world.block.shapes.BlockShape)1