Added PartInstance->Collides function

This commit is contained in:
andreja6
2020-03-15 11:46:06 -07:00
parent 73a6b72c20
commit 0090c6c8a1
2 changed files with 29 additions and 1 deletions

View File

@@ -206,8 +206,27 @@ void PartInstance::setCFrame(CoordinateFrame coordinateFrame)
// Can probably be deleted
CoordinateFrame PartInstance::getCFrameRenderBased()
{
return CoordinateFrame(getCFrame().rotation,Vector3(getCFrame().translation.x, getCFrame().translation.y, getCFrame().translation.z));
return cFrame;//CoordinateFrame(getCFrame().rotation,Vector3(getCFrame().translation.x, getCFrame().translation.y, getCFrame().translation.z));
}
bool PartInstance::collides(PartInstance * part)
{
if(shape == Enum::Shape::Block)
{
if(part->shape == Enum::Shape::Block)
return G3D::CollisionDetection::fixedSolidBoxIntersectsFixedSolidBox(getBox(), part->getBox());
else
return G3D::CollisionDetection::fixedSolidSphereIntersectsFixedSolidBox(part->getSphere(), getBox());
}
else
{
if(part->shape == Enum::Shape::Block)
return G3D::CollisionDetection::fixedSolidSphereIntersectsFixedSolidBox(getSphere(), part->getBox());
else
return G3D::CollisionDetection::fixedSolidSphereIntersectsFixedSolidSphere(getSphere(), part->getSphere());
}
}
#ifdef NEW_BOX_RENDER
Box PartInstance::getBox()
{
@@ -216,6 +235,13 @@ Box PartInstance::getBox()
itemBox = c.toWorldSpace(box);
return itemBox;
}
Sphere PartInstance::getSphere()
{
Sphere sphere = Sphere(Vector3(0,0,0), size.y/2);
CoordinateFrame c = getCFrameRenderBased();
//itemBox = c.toWorldSpace(Sphere);
return sphere;//itemBox;
}
#else
Box PartInstance::getBox()
{