Added limbo functionality
This commit is contained in:
parent
b8e6b83148
commit
f527d329a2
|
@ -40,6 +40,7 @@ void Octree::AddObject(UniquePointer< ICustomBody > customBodyRef)
|
||||||
data.next = NULL;
|
data.next = NULL;
|
||||||
data.prev = NULL;
|
data.prev = NULL;
|
||||||
data.customBodyRef = customBodyRef;
|
data.customBodyRef = customBodyRef;
|
||||||
|
data.limbo = false;
|
||||||
this->mapReferences.insert(std::pair <ICustomBody*, unsigned int> (data.customBodyRef, this->leafData.size()));
|
this->mapReferences.insert(std::pair <ICustomBody*, unsigned int> (data.customBodyRef, this->leafData.size()));
|
||||||
this->leafData.push_back(data);
|
this->leafData.push_back(data);
|
||||||
|
|
||||||
|
@ -64,6 +65,33 @@ void Octree::MoveToUpdateQueue(UniquePointer< ICustomBody > customBodyRef)
|
||||||
this->updateQueue.push_back(&this->leafData[this->mapReferences[customBodyRef]]);*/
|
this->updateQueue.push_back(&this->leafData[this->mapReferences[customBodyRef]]);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Octree::MoveToLimbo(const ICustomBody* customBodyRef)
|
||||||
|
{
|
||||||
|
auto object = this->mapReferences.find(customBodyRef);
|
||||||
|
|
||||||
|
unsigned int tempRef = object->second;
|
||||||
|
|
||||||
|
this->leafData[tempRef].limbo = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Octree::IsInLimbo(const ICustomBody* customBodyRef)
|
||||||
|
{
|
||||||
|
auto object = this->mapReferences.find(customBodyRef);
|
||||||
|
|
||||||
|
unsigned int tempRef = object->second;
|
||||||
|
|
||||||
|
return this->leafData[tempRef].limbo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Octree::ReleaseFromLimbo(const ICustomBody* customBodyRef)
|
||||||
|
{
|
||||||
|
auto object = this->mapReferences.find(customBodyRef);
|
||||||
|
|
||||||
|
unsigned int tempRef = object->second;
|
||||||
|
|
||||||
|
this->leafData[tempRef].limbo = false;
|
||||||
|
}
|
||||||
|
|
||||||
void Octree::DestroyObject(UniquePointer< ICustomBody > customBodyRef)
|
void Octree::DestroyObject(UniquePointer< ICustomBody > customBodyRef)
|
||||||
{
|
{
|
||||||
std::map<const ICustomBody*, unsigned int>::iterator it = this->mapReferences.find(customBodyRef);
|
std::map<const ICustomBody*, unsigned int>::iterator it = this->mapReferences.find(customBodyRef);
|
||||||
|
@ -86,7 +114,7 @@ std::vector<ICustomBody*>& Octree::Sample(ICustomBody* customBodyRef, std::vecto
|
||||||
|
|
||||||
for(unsigned int i = 0; i<this->leafData.size(); i++)
|
for(unsigned int i = 0; i<this->leafData.size(); i++)
|
||||||
{
|
{
|
||||||
if(tempRef != i) if(this->leafData[tempRef].container.Intersects(this->leafData[i].container))
|
if(tempRef != i && !this->leafData[i].limbo) if(this->leafData[tempRef].container.Intersects(this->leafData[i].container))
|
||||||
{
|
{
|
||||||
updateList.push_back(this->leafData[i].customBodyRef);
|
updateList.push_back(this->leafData[i].customBodyRef);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +127,7 @@ std::vector<ICustomBody*>& Octree::Sample(const Oyster::Collision3D::ICollideabl
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i<this->leafData.size(); i++)
|
for(unsigned int i = 0; i<this->leafData.size(); i++)
|
||||||
{
|
{
|
||||||
if(this->leafData[i].container.Intersects(collideable))
|
if(!this->leafData[i].limbo && this->leafData[i].container.Intersects(collideable))
|
||||||
{
|
{
|
||||||
updateList.push_back(this->leafData[i].customBodyRef);
|
updateList.push_back(this->leafData[i].customBodyRef);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +149,7 @@ void Octree::Visit(ICustomBody* customBodyRef, VisitorAction hitAction )
|
||||||
|
|
||||||
for(unsigned int i = 0; i<this->leafData.size(); i++)
|
for(unsigned int i = 0; i<this->leafData.size(); i++)
|
||||||
{
|
{
|
||||||
if(tempRef != i) if(this->leafData[tempRef].container.Intersects(this->leafData[i].container))
|
if(tempRef != i && !this->leafData[i].limbo) if(this->leafData[tempRef].container.Intersects(this->leafData[i].container))
|
||||||
{
|
{
|
||||||
hitAction(*this, tempRef, i);
|
hitAction(*this, tempRef, i);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +160,7 @@ void Octree::Visit(const Oyster::Collision3D::ICollideable& collideable, void* a
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i<this->leafData.size(); i++)
|
for(unsigned int i = 0; i<this->leafData.size(); i++)
|
||||||
{
|
{
|
||||||
if(collideable.Intersects(this->leafData[i].container))
|
if(!this->leafData[i].limbo && collideable.Intersects(this->leafData[i].container))
|
||||||
{
|
{
|
||||||
hitAction( this->GetCustomBody(i), args );
|
hitAction( this->GetCustomBody(i), args );
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ namespace Oyster
|
||||||
|
|
||||||
::Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef;
|
::Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef;
|
||||||
|
|
||||||
|
bool limbo;
|
||||||
|
|
||||||
unsigned int queueRef;
|
unsigned int queueRef;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,6 +50,10 @@ namespace Oyster
|
||||||
|
|
||||||
void MoveToUpdateQueue(::Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef);
|
void MoveToUpdateQueue(::Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef);
|
||||||
|
|
||||||
|
void MoveToLimbo(const ICustomBody* customBodyRef);
|
||||||
|
bool IsInLimbo(const ICustomBody* customBodyRef);
|
||||||
|
void ReleaseFromLimbo(const ICustomBody* customBodyRef);
|
||||||
|
|
||||||
void DestroyObject(::Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef);
|
void DestroyObject(::Utility::DynamicMemory::UniquePointer< ICustomBody > customBodyRef);
|
||||||
|
|
||||||
std::vector<ICustomBody*>& Sample(ICustomBody* customBodyRef, std::vector<ICustomBody*>& updateList);
|
std::vector<ICustomBody*>& Sample(ICustomBody* customBodyRef, std::vector<ICustomBody*>& updateList);
|
||||||
|
@ -66,6 +72,7 @@ namespace Oyster
|
||||||
private:
|
private:
|
||||||
std::vector < Data > leafData;
|
std::vector < Data > leafData;
|
||||||
std::vector < Data* > updateQueue;
|
std::vector < Data* > updateQueue;
|
||||||
|
std::vector < Data* > limbo;
|
||||||
|
|
||||||
std::map< const ICustomBody*, unsigned int > mapReferences;
|
std::map< const ICustomBody*, unsigned int > mapReferences;
|
||||||
|
|
||||||
|
|
|
@ -237,17 +237,16 @@ void API_Impl::Update()
|
||||||
|
|
||||||
bool API_Impl::IsInLimbo( const ICustomBody* objRef )
|
bool API_Impl::IsInLimbo( const ICustomBody* objRef )
|
||||||
{
|
{
|
||||||
//! @todo TODO: implement stub
|
return this->worldScene.IsInLimbo( objRef );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void API_Impl::MoveToLimbo( const ICustomBody* objRef )
|
void API_Impl::MoveToLimbo( const ICustomBody* objRef )
|
||||||
{
|
{
|
||||||
/** @todo TODO: Fix this function.*/
|
this->worldScene.MoveToLimbo( objRef );
|
||||||
}
|
}
|
||||||
void API_Impl::ReleaseFromLimbo( const ICustomBody* objRef )
|
void API_Impl::ReleaseFromLimbo( const ICustomBody* objRef )
|
||||||
{
|
{
|
||||||
/** @todo TODO: Fix this function.*/
|
this->worldScene.ReleaseFromLimbo( objRef );
|
||||||
}
|
}
|
||||||
|
|
||||||
void API_Impl::AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle )
|
void API_Impl::AddObject( ::Utility::DynamicMemory::UniquePointer<ICustomBody> handle )
|
||||||
|
|
Loading…
Reference in New Issue