use of org.terasology.engine.physics.shapes.CollisionShape 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));
}
}
use of org.terasology.engine.physics.shapes.CollisionShape in project Terasology by MovingBlocks.
the class BlockShapeImpl method getCollisionShape.
@Override
public CollisionShape getCollisionShape(Rotation rot) {
Rotation simplifiedRot = applySymmetry(rot);
CollisionShape result = collisionShape.get(simplifiedRot);
if (result == null && baseCollisionShape != null) {
result = baseCollisionShape.rotate(new Quaternionf(simplifiedRot.orientation()));
collisionShape.put(simplifiedRot, result);
}
return result;
}
Aggregations