us.ihmc.simulationconstructionset.physics.collision.simple.SimpleCollisionShape Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simulation-construction-set
Show all versions of simulation-construction-set
Simulation Construction Set
package us.ihmc.simulationconstructionset.physics.collision.simple;
import us.ihmc.euclid.geometry.BoundingBox3D;
import us.ihmc.euclid.transform.RigidBodyTransform;
import us.ihmc.simulationconstructionset.physics.CollisionShape;
import us.ihmc.simulationconstructionset.physics.CollisionShapeDescription;
public class SimpleCollisionShape implements CollisionShape
{
private final CollisionShapeDescription collisionShapeDescription;
private final CollisionShapeDescription transformedCollisionShapeDescription;
private final RigidBodyTransform transformToWorld = new RigidBodyTransform();
private int groupMask = 0x00;
private int collisionMask = 0x00;
private boolean isGround = false;
public SimpleCollisionShape(CollisionShapeDescription collisionShapeDescription)
{
this.collisionShapeDescription = collisionShapeDescription;
transformedCollisionShapeDescription = collisionShapeDescription.copy();
}
@Override
public boolean isGround()
{
return isGround;
}
@Override
public void setIsGround(boolean isGround)
{
this.isGround = isGround;
}
@Override
public CollisionShapeDescription getCollisionShapeDescription()
{
return collisionShapeDescription;
}
@Override
public int getCollisionGroup()
{
return groupMask;
}
@Override
public int getCollisionMask()
{
return collisionMask;
}
@Override
public void setCollisionGroup(int groupMask)
{
this.groupMask = groupMask;
}
@Override
public void setCollisionMask(int collisionMask)
{
this.collisionMask = collisionMask;
}
@Override
public void getTransformToWorld(RigidBodyTransform transformToWorldToPack)
{
transformToWorldToPack.set(transformToWorld);
}
@Override
public void setTransformToWorld(RigidBodyTransform transformToWorld)
{
this.transformToWorld.set(transformToWorld);
}
@Override
public CollisionShapeDescription getTransformedCollisionShapeDescription()
{
return transformedCollisionShapeDescription;
}
@Override
public void computeTransformedCollisionShape()
{
transformedCollisionShapeDescription.setFrom(collisionShapeDescription);
getTransformToWorld(transformToWorld);
transformedCollisionShapeDescription.applyTransform(transformToWorld);
}
@Override
public void getBoundingBox(BoundingBox3D boundingBoxToPack)
{
transformedCollisionShapeDescription.getBoundingBox(boundingBoxToPack);
}
}