Added PartInstance->Collides function
This commit is contained in:
@@ -206,8 +206,27 @@ void PartInstance::setCFrame(CoordinateFrame coordinateFrame)
|
|||||||
// Can probably be deleted
|
// Can probably be deleted
|
||||||
CoordinateFrame PartInstance::getCFrameRenderBased()
|
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
|
#ifdef NEW_BOX_RENDER
|
||||||
Box PartInstance::getBox()
|
Box PartInstance::getBox()
|
||||||
{
|
{
|
||||||
@@ -216,6 +235,13 @@ Box PartInstance::getBox()
|
|||||||
itemBox = c.toWorldSpace(box);
|
itemBox = c.toWorldSpace(box);
|
||||||
return itemBox;
|
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
|
#else
|
||||||
Box PartInstance::getBox()
|
Box PartInstance::getBox()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,10 +31,12 @@ public:
|
|||||||
void setParent(Instance* parent);
|
void setParent(Instance* parent);
|
||||||
void setPosition(Vector3);
|
void setPosition(Vector3);
|
||||||
void setVelocity(Vector3);
|
void setVelocity(Vector3);
|
||||||
|
bool collides(PartInstance * part);
|
||||||
void setRotVelocity(Vector3);
|
void setRotVelocity(Vector3);
|
||||||
CoordinateFrame getCFrame();
|
CoordinateFrame getCFrame();
|
||||||
void setCFrame(CoordinateFrame);
|
void setCFrame(CoordinateFrame);
|
||||||
Box getBox();
|
Box getBox();
|
||||||
|
Sphere getSphere();
|
||||||
Box getScaledBox();
|
Box getScaledBox();
|
||||||
CoordinateFrame getCFrameRenderBased();
|
CoordinateFrame getCFrameRenderBased();
|
||||||
Vector3 getSize();
|
Vector3 getSize();
|
||||||
|
|||||||
Reference in New Issue
Block a user