Stub response to new ICollideAble method
Stubbed: Box, BoxAxisAligned, Frustrum Fully implemented: Line & Universe
This commit is contained in:
parent
da996a5deb
commit
de0078265c
|
@ -54,6 +54,12 @@ bool Box::Intersects( const ICollideable &target ) const
|
|||
}
|
||||
}
|
||||
|
||||
bool Box::Intersects( const ICollideable &target, Float3 &worldPointOfContact ) const
|
||||
{
|
||||
//! @todo TODO: implement stub properly
|
||||
return this->Intersects( target );
|
||||
}
|
||||
|
||||
bool Box::Contains( const ICollideable &target ) const
|
||||
{
|
||||
switch( target.type )
|
||||
|
|
|
@ -34,6 +34,7 @@ namespace Oyster { namespace Collision3D
|
|||
|
||||
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
|
||||
bool Intersects( const ICollideable &target ) const;
|
||||
bool Intersects( const ICollideable &target, ::Oyster::Math::Float3 &worldPointOfContact ) const;
|
||||
bool Contains( const ICollideable &target ) const;
|
||||
};
|
||||
} }
|
||||
|
|
|
@ -57,6 +57,12 @@ bool BoxAxisAligned::Intersects( const ICollideable &target ) const
|
|||
}
|
||||
}
|
||||
|
||||
bool BoxAxisAligned::Intersects( const ICollideable &target, Float3 &worldPointOfContact ) const
|
||||
{
|
||||
//! @todo TODO: implement stub properly
|
||||
return this->Intersects( target );
|
||||
}
|
||||
|
||||
bool BoxAxisAligned::Contains( const ICollideable &target ) const
|
||||
{
|
||||
switch( target.type )
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace Oyster { namespace Collision3D
|
|||
|
||||
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
|
||||
bool Intersects( const ICollideable &target ) const;
|
||||
bool Intersects( const ICollideable &target, ::Oyster::Math::Float3 &worldPointOfContact ) const;
|
||||
bool Contains( const ICollideable &target ) const;
|
||||
};
|
||||
} }
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include "Frustrum.h"
|
||||
#include "OysterCollision3D.h"
|
||||
|
||||
using namespace Oyster::Math;
|
||||
using namespace Oyster::Collision3D;
|
||||
using namespace ::Oyster::Math;
|
||||
using namespace ::Oyster::Collision3D;
|
||||
|
||||
namespace PrivateStatic
|
||||
{
|
||||
|
@ -218,6 +218,12 @@ bool Frustrum::Intersects( const ICollideable &target ) const
|
|||
}
|
||||
}
|
||||
|
||||
bool Frustrum::Intersects( const ICollideable &target, Float3 &worldPointOfContact ) const
|
||||
{
|
||||
//! @todo TODO: implement stub properly
|
||||
return this->Intersects( target );
|
||||
}
|
||||
|
||||
bool Frustrum::Contains( const ICollideable &target ) const
|
||||
{
|
||||
switch( target.type )
|
||||
|
|
|
@ -39,6 +39,7 @@ namespace Oyster { namespace Collision3D
|
|||
|
||||
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
|
||||
bool Intersects( const ICollideable &target ) const;
|
||||
bool Intersects( const ICollideable &target, Oyster::Math::Float3 &worldPointOfContact ) const;
|
||||
bool Contains( const ICollideable &target ) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Oyster { namespace Collision3D //! Contains a collection of 3D shapes
|
|||
virtual ~ICollideable();
|
||||
|
||||
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const = 0;
|
||||
virtual bool Intersects( const ICollideable &target, Oyster::Math::Float3 &worldPointOfContact ) const = 0;
|
||||
virtual bool Intersects( const ICollideable &target, ::Oyster::Math::Float3 &worldPointOfContact ) const = 0;
|
||||
virtual bool Intersects( const ICollideable &target ) const = 0;
|
||||
virtual bool Contains( const ICollideable &target ) const = 0;
|
||||
};
|
||||
|
|
|
@ -47,7 +47,28 @@ bool Line::Intersects( const ICollideable &target ) const
|
|||
}
|
||||
|
||||
if( this->ray.Intersects(target) ) if( this->ray.collisionDistance >= 0.0f ) if( this->ray.collisionDistance <= this->length )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
this->ray.collisionDistance = 0.0f;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Line::Intersects( const ICollideable &target, Float3 &worldPointOfContact ) const
|
||||
{
|
||||
if( target.type == Type_universe )
|
||||
{
|
||||
this->ray.collisionDistance = 0.0f;
|
||||
worldPointOfContact = this->ray.origin;
|
||||
return true;
|
||||
}
|
||||
|
||||
if( this->ray.Intersects(target) ) if( this->ray.collisionDistance >= 0.0f ) if( this->ray.collisionDistance <= this->length )
|
||||
{
|
||||
worldPointOfContact = this->ray.origin + this->ray.direction * this->ray.collisionDistance;
|
||||
return true;
|
||||
}
|
||||
|
||||
this->ray.collisionDistance = 0.0f;
|
||||
return false;
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace Oyster { namespace Collision3D
|
|||
|
||||
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
|
||||
bool Intersects( const ICollideable &target ) const;
|
||||
bool Intersects( const ICollideable &target, ::Oyster::Math::Float3 &worldPointOfContact ) const;
|
||||
bool Contains( const ICollideable &target ) const;
|
||||
};
|
||||
} }
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "Universe.h"
|
||||
#include "OysterCollision3D.h"
|
||||
|
||||
using namespace ::Utility::Value;
|
||||
using namespace ::Oyster::Math;
|
||||
using namespace ::Oyster::Collision3D;
|
||||
using namespace ::Utility::DynamicMemory;
|
||||
|
||||
|
@ -29,6 +31,46 @@ bool Universe::Intersects( const ICollideable &target ) const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Universe::Intersects( const ICollideable &target, Float3 &worldPointOfContact ) const
|
||||
{ // universe touches everything
|
||||
switch( target.type )
|
||||
{
|
||||
case Type_point:
|
||||
worldPointOfContact = ((Point*)&target)->center;
|
||||
break;
|
||||
case Type_sphere:
|
||||
worldPointOfContact = ((Sphere*)&target)->center;
|
||||
break;
|
||||
case Type_plane:
|
||||
worldPointOfContact = ((Plane*)&target)->normal * ((Plane*)&target)->phasing;
|
||||
break;
|
||||
case Type_box_axis_aligned:
|
||||
worldPointOfContact = Average( ((BoxAxisAligned*)&target)->minVertex, ((BoxAxisAligned*)&target)->maxVertex );
|
||||
break;
|
||||
case Type_box:
|
||||
worldPointOfContact = ((Box*)&target)->center;
|
||||
break;
|
||||
case Type_frustrum:
|
||||
worldPointOfContact = Average( ((Frustrum*)&target)->leftPlane.normal * ((Frustrum*)&target)->leftPlane.phasing, ((Frustrum*)&target)->rightPlane.normal * ((Frustrum*)&target)->rightPlane.phasing );
|
||||
worldPointOfContact = Average( worldPointOfContact, Average( ((Frustrum*)&target)->bottomPlane.normal * ((Frustrum*)&target)->bottomPlane.phasing, ((Frustrum*)&target)->topPlane.normal * ((Frustrum*)&target)->topPlane.phasing ) );
|
||||
worldPointOfContact = Average( worldPointOfContact, Average( ((Frustrum*)&target)->nearPlane.normal * ((Frustrum*)&target)->nearPlane.phasing, ((Frustrum*)&target)->farPlane.normal * ((Frustrum*)&target)->farPlane.phasing ) );
|
||||
break;
|
||||
case Type_ray:
|
||||
((Ray*)&target)->collisionDistance = 0.0f;
|
||||
worldPointOfContact = ((Ray*)&target)->origin;
|
||||
break;
|
||||
case Type_line:
|
||||
((Line*)&target)->ray.collisionDistance = 0.0f;
|
||||
worldPointOfContact = ((Line*)&target)->ray.origin;
|
||||
break;
|
||||
default:
|
||||
worldPointOfContact = Float3::null;
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Universe::Contains( const ICollideable &target ) const
|
||||
{ return true; } // universe contains everything
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace Oyster { namespace Collision3D
|
|||
|
||||
virtual ::Utility::DynamicMemory::UniquePointer<ICollideable> Clone( ) const;
|
||||
bool Intersects( const ICollideable &target ) const;
|
||||
bool Intersects( const ICollideable &target, ::Oyster::Math::Float3 &worldPointOfContact ) const;
|
||||
bool Contains( const ICollideable &target ) const;
|
||||
};
|
||||
} }
|
||||
|
|
Loading…
Reference in New Issue