Implemented a temporary collision test update
Will only call the subscribed CollisioEventAction whenevera collision is detected.
This commit is contained in:
parent
1a06c7c7e6
commit
026b427deb
Binary file not shown.
|
@ -11,6 +11,22 @@ using namespace ::Utility::DynamicMemory;
|
||||||
|
|
||||||
API_Impl API_instance;
|
API_Impl API_instance;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
void OnPossibleCollision( Octree& worldScene, unsigned int protoTempRef, unsigned int deuterTempRef )
|
||||||
|
{ /** @todo TODO: OnPossibleCollision is a temporary solution .*/
|
||||||
|
auto proto = worldScene.GetCustomBody( protoTempRef );
|
||||||
|
auto deuter = worldScene.GetCustomBody( deuterTempRef );
|
||||||
|
|
||||||
|
float deltaWhen;
|
||||||
|
Float3 worldWhere;
|
||||||
|
if( deuter->Intersects(*deuter, 1.0f, deltaWhen, worldWhere) )
|
||||||
|
{
|
||||||
|
proto->CallSubscription( proto, deuter );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Float4x4 & MomentOfInertia::CreateSphereMatrix( const Float mass, const Float radius)
|
Float4x4 & MomentOfInertia::CreateSphereMatrix( const Float mass, const Float radius)
|
||||||
{
|
{
|
||||||
return Formula::MomentOfInertia::Sphere(mass, radius);
|
return Formula::MomentOfInertia::Sphere(mass, radius);
|
||||||
|
@ -80,8 +96,25 @@ void API_Impl::SetSubscription( API::EventAction_Destruction functionPointer )
|
||||||
}
|
}
|
||||||
|
|
||||||
void API_Impl::Update()
|
void API_Impl::Update()
|
||||||
{
|
{ /** @todo TODO: Update is a temporary solution .*/
|
||||||
/** @todo TODO: Fix this function.*/
|
::std::vector<ICustomBody*> updateList;
|
||||||
|
auto proto = this->worldScene.Sample( Universe(), updateList ).begin();
|
||||||
|
for( ; proto != updateList.end(); ++proto )
|
||||||
|
{
|
||||||
|
this->worldScene.Visit( *proto, OnPossibleCollision );
|
||||||
|
}
|
||||||
|
|
||||||
|
proto = updateList.begin();
|
||||||
|
for( ; proto != updateList.end(); ++proto )
|
||||||
|
{
|
||||||
|
switch( (*proto)->Update(this->updateFrameLength) )
|
||||||
|
{
|
||||||
|
case UpdateState_altered:
|
||||||
|
this->worldScene.SetAsAltered( this->worldScene.GetTemporaryReferenceOf(*proto) );
|
||||||
|
case UpdateState_resting: default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool API_Impl::IsInLimbo( const ICustomBody* objRef )
|
bool API_Impl::IsInLimbo( const ICustomBody* objRef )
|
||||||
|
|
|
@ -42,6 +42,11 @@ UniquePointer<ICustomBody> SimpleRigidBody::Clone() const
|
||||||
return new SimpleRigidBody( *this );
|
return new SimpleRigidBody( *this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleRigidBody::CallSubscription( const ICustomBody *proto, const ICustomBody *deuter )
|
||||||
|
{
|
||||||
|
this->collisionAction( proto, deuter );
|
||||||
|
}
|
||||||
|
|
||||||
bool SimpleRigidBody::IsAffectedByGravity() const
|
bool SimpleRigidBody::IsAffectedByGravity() const
|
||||||
{
|
{
|
||||||
return !this->ignoreGravity;
|
return !this->ignoreGravity;
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace Oyster { namespace Physics
|
||||||
|
|
||||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const;
|
::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const;
|
||||||
|
|
||||||
|
void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter );
|
||||||
bool IsAffectedByGravity() const;
|
bool IsAffectedByGravity() const;
|
||||||
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
|
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
|
||||||
bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const;
|
bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const;
|
||||||
|
|
|
@ -44,6 +44,11 @@ UniquePointer<ICustomBody> SphericalRigidBody::Clone() const
|
||||||
return new SphericalRigidBody( *this );
|
return new SphericalRigidBody( *this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SphericalRigidBody::CallSubscription( const ICustomBody *proto, const ICustomBody *deuter )
|
||||||
|
{
|
||||||
|
this->collisionAction( proto, deuter );
|
||||||
|
}
|
||||||
|
|
||||||
bool SphericalRigidBody::IsAffectedByGravity() const
|
bool SphericalRigidBody::IsAffectedByGravity() const
|
||||||
{
|
{
|
||||||
return !this->ignoreGravity;
|
return !this->ignoreGravity;
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace Oyster { namespace Physics
|
||||||
|
|
||||||
::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const;
|
::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const;
|
||||||
|
|
||||||
bool IsSubscribingCollisions() const;
|
void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter );
|
||||||
bool IsAffectedByGravity() const;
|
bool IsAffectedByGravity() const;
|
||||||
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
|
bool Intersects( const ICustomBody &object, ::Oyster::Math::Float timeStepLength, ::Oyster::Math::Float &deltaWhen, ::Oyster::Math::Float3 &worldPointOfContact ) const;
|
||||||
bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const;
|
bool Intersects( const ::Oyster::Collision3D::ICollideable &shape ) const;
|
||||||
|
|
|
@ -246,6 +246,11 @@ namespace Oyster
|
||||||
********************************************************/
|
********************************************************/
|
||||||
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const = 0;
|
virtual ::Utility::DynamicMemory::UniquePointer<ICustomBody> Clone() const = 0;
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
* @todo TODO: need doc
|
||||||
|
********************************************************/
|
||||||
|
virtual void CallSubscription( const ICustomBody *proto, const ICustomBody *deuter ) = 0;
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* @return true if Engine should apply gravity on this object.
|
* @return true if Engine should apply gravity on this object.
|
||||||
********************************************************/
|
********************************************************/
|
||||||
|
|
Loading…
Reference in New Issue