|
|
@ -100,7 +100,7 @@ void plSceneNode::Read(hsStream* s, hsResMgr* mgr) |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
n = s->ReadLE32(); |
|
|
|
n = s->ReadLE32(); |
|
|
|
fSceneObjects.Reset(); |
|
|
|
fSceneObjects.clear(); |
|
|
|
for( i = 0; i < n; i++ ) |
|
|
|
for( i = 0; i < n; i++ ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
plNodeRefMsg* refMsg = new plNodeRefMsg(GetKey(), plRefMsg::kOnCreate, i, plNodeRefMsg::kObject); |
|
|
|
plNodeRefMsg* refMsg = new plNodeRefMsg(GetKey(), plRefMsg::kOnCreate, i, plNodeRefMsg::kObject); |
|
|
@ -108,7 +108,7 @@ void plSceneNode::Read(hsStream* s, hsResMgr* mgr) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
n = s->ReadLE32(); |
|
|
|
n = s->ReadLE32(); |
|
|
|
fGenericPool.Reset(); |
|
|
|
fGenericPool.clear(); |
|
|
|
for( i = 0; i < n; i++ ) |
|
|
|
for( i = 0; i < n; i++ ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
plNodeRefMsg* refMsg = new plNodeRefMsg(GetKey(), plRefMsg::kOnCreate, -1, plNodeRefMsg::kGeneric); |
|
|
|
plNodeRefMsg* refMsg = new plNodeRefMsg(GetKey(), plRefMsg::kOnCreate, -1, plNodeRefMsg::kGeneric); |
|
|
@ -122,12 +122,12 @@ void plSceneNode::Write(hsStream* s, hsResMgr* mgr) |
|
|
|
|
|
|
|
|
|
|
|
int i; |
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
s->WriteLE32(fSceneObjects.GetCount()); |
|
|
|
s->WriteLE32(fSceneObjects.size()); |
|
|
|
for( i = 0; i < fSceneObjects.GetCount(); i++ ) |
|
|
|
for( i = 0; i < fSceneObjects.size(); i++ ) |
|
|
|
mgr->WriteKey(s,fSceneObjects[i]); |
|
|
|
mgr->WriteKey(s,fSceneObjects[i]); |
|
|
|
|
|
|
|
|
|
|
|
s->WriteLE32(fGenericPool.GetCount()); |
|
|
|
s->WriteLE32(fGenericPool.size()); |
|
|
|
for( i = 0; i < fGenericPool.GetCount(); i++ ) |
|
|
|
for( i = 0; i < fGenericPool.size(); i++ ) |
|
|
|
mgr->WriteKey(s, fGenericPool[i]); |
|
|
|
mgr->WriteKey(s, fGenericPool[i]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -189,7 +189,7 @@ plSpaceTree* plSceneNode::IBuildSpaceTree() |
|
|
|
bnd.Reset(&zero); |
|
|
|
bnd.Reset(&zero); |
|
|
|
|
|
|
|
|
|
|
|
int i; |
|
|
|
int i; |
|
|
|
for( i = 0; i < fDrawPool.GetCount(); i++ ) |
|
|
|
for( i = 0; i < fDrawPool.size(); i++ ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( fDrawPool[i] ) |
|
|
|
if( fDrawPool[i] ) |
|
|
|
maker.AddLeaf(fDrawPool[i]->GetSpaceTree()->GetWorldBounds()); |
|
|
|
maker.AddLeaf(fDrawPool[i]->GetSpaceTree()->GetWorldBounds()); |
|
|
@ -211,13 +211,13 @@ plSpaceTree* plSceneNode::ITrashSpaceTree() |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::IDirtySpaceTree() |
|
|
|
void plSceneNode::IDirtySpaceTree() |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
for (size_t i = 0; i < fDrawPool.size(); ++i) |
|
|
|
for( i = 0; i < fDrawPool.GetCount(); i++ ) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if( fDrawPool[i] && fDrawPool[i]->GetSpaceTree()->IsDirty() ) |
|
|
|
plDrawable* drawable = fDrawPool[i]; |
|
|
|
|
|
|
|
if (drawable && drawable->GetSpaceTree()->IsDirty() ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fDrawPool[i]->GetSpaceTree()->Refresh(); |
|
|
|
drawable->GetSpaceTree()->Refresh(); |
|
|
|
fSpaceTree->MoveLeaf(i, fDrawPool[i]->GetSpaceTree()->GetWorldBounds()); |
|
|
|
fSpaceTree->MoveLeaf(i, drawable->GetSpaceTree()->GetWorldBounds()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -225,9 +225,7 @@ void plSceneNode::IDirtySpaceTree() |
|
|
|
plSpaceTree* plSceneNode::GetSpaceTree() |
|
|
|
plSpaceTree* plSceneNode::GetSpaceTree() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!fSpaceTree) |
|
|
|
if (!fSpaceTree) |
|
|
|
{ |
|
|
|
|
|
|
|
IBuildSpaceTree(); |
|
|
|
IBuildSpaceTree(); |
|
|
|
} |
|
|
|
|
|
|
|
IDirtySpaceTree(); |
|
|
|
IDirtySpaceTree(); |
|
|
|
return fSpaceTree; |
|
|
|
return fSpaceTree; |
|
|
|
} |
|
|
|
} |
|
|
@ -237,23 +235,19 @@ void plSceneNode::ISetDrawable(plDrawable* d) |
|
|
|
if( !d ) |
|
|
|
if( !d ) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (fDrawPool.Find(d) == fDrawPool.kMissingIndex) |
|
|
|
if (std::find(fDrawPool.begin(), fDrawPool.end(), d) == fDrawPool.end()) { |
|
|
|
{ |
|
|
|
fDrawPool.push_back(d); |
|
|
|
fDrawPool.Append(d); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ITrashSpaceTree(); |
|
|
|
ITrashSpaceTree(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::ISetAudible(plAudible* a) |
|
|
|
void plSceneNode::ISetAudible(plAudible* a) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( !a ) |
|
|
|
if( !a ) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if( fAudioPool.kMissingIndex == fAudioPool.Find(a) ) |
|
|
|
if (std::find(fAudioPool.begin(), fAudioPool.end(), a) == fAudioPool.end()) |
|
|
|
{ |
|
|
|
fAudioPool.push_back(a); |
|
|
|
fAudioPool.Append(a); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::ISetPhysical(plPhysical* p) |
|
|
|
void plSceneNode::ISetPhysical(plPhysical* p) |
|
|
@ -261,17 +255,17 @@ void plSceneNode::ISetPhysical(plPhysical* p) |
|
|
|
if( !p ) |
|
|
|
if( !p ) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if( fSimulationPool.kMissingIndex == fSimulationPool.Find(p) ) |
|
|
|
if (std::find(fSimulationPool.begin(), fSimulationPool.end(), p) == fSimulationPool.end()) |
|
|
|
{ |
|
|
|
fSimulationPool.push_back(p); |
|
|
|
fSimulationPool.Append(p); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::ISetObject(plSceneObject* o) |
|
|
|
void plSceneNode::ISetObject(plSceneObject* o) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( o && (fSceneObjects.kMissingIndex == fSceneObjects.Find(o)) ) |
|
|
|
if (!o) |
|
|
|
{ |
|
|
|
return; |
|
|
|
fSceneObjects.Append(o); |
|
|
|
|
|
|
|
|
|
|
|
if (std::find(fSceneObjects.begin(), fSceneObjects.end(), o) == fSceneObjects.end()) |
|
|
|
|
|
|
|
fSceneObjects.push_back(o); |
|
|
|
|
|
|
|
|
|
|
|
// MF_NET_GROUPS_TEST
|
|
|
|
// MF_NET_GROUPS_TEST
|
|
|
|
// This will have no effect on members of NetGroupConstants
|
|
|
|
// This will have no effect on members of NetGroupConstants
|
|
|
@ -279,13 +273,11 @@ void plSceneNode::ISetObject(plSceneObject* o) |
|
|
|
|
|
|
|
|
|
|
|
o->SetSceneNode(GetKey()); |
|
|
|
o->SetSceneNode(GetKey()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::ISetLight(plLightInfo* l) |
|
|
|
void plSceneNode::ISetLight(plLightInfo* l) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( fLightPool.kMissingIndex == fLightPool.Find(l) ) |
|
|
|
if (std::find(fLightPool.begin(), fLightPool.end(), l) == fLightPool.end()) |
|
|
|
fLightPool.Append( l ); |
|
|
|
fLightPool.push_back(l); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::ISetOccluder(plOccluder* o) |
|
|
|
void plSceneNode::ISetOccluder(plOccluder* o) |
|
|
@ -298,25 +290,24 @@ void plSceneNode::ISetOccluder(plOccluder* o) |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::ISetGeneric(hsKeyedObject* k) |
|
|
|
void plSceneNode::ISetGeneric(hsKeyedObject* k) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if( fGenericPool.kMissingIndex == fGenericPool.Find(k) ) |
|
|
|
if (std::find(fGenericPool.begin(), fGenericPool.end(), k) == fGenericPool.end()) |
|
|
|
fGenericPool.Append(k); |
|
|
|
fGenericPool.push_back(k); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::IRemoveDrawable(plDrawable* d) |
|
|
|
void plSceneNode::IRemoveDrawable(plDrawable* d) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int idx = fDrawPool.Find(d); |
|
|
|
auto it = std::find(fDrawPool.begin(), fDrawPool.end(), d); |
|
|
|
if( idx != fDrawPool.kMissingIndex ) |
|
|
|
if (it != fDrawPool.end()) { |
|
|
|
fDrawPool.Remove(idx); |
|
|
|
fDrawPool.erase(it); |
|
|
|
|
|
|
|
|
|
|
|
ITrashSpaceTree(); |
|
|
|
ITrashSpaceTree(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::IRemoveAudible(plAudible* a) |
|
|
|
void plSceneNode::IRemoveAudible(plAudible* a) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int idx = fAudioPool.Find(a); |
|
|
|
auto it = std::find(fAudioPool.begin(), fAudioPool.end(), a); |
|
|
|
if( idx != fAudioPool.kMissingIndex ) |
|
|
|
if (it != fAudioPool.end()) |
|
|
|
fAudioPool.Remove(idx); |
|
|
|
fAudioPool.erase(it); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::IRemovePhysical(plPhysical* p) |
|
|
|
void plSceneNode::IRemovePhysical(plPhysical* p) |
|
|
@ -337,27 +328,25 @@ void plSceneNode::IRemovePhysical(plPhysical* p) |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
int idx = fSimulationPool.Find(p); |
|
|
|
auto it = std::find(fSimulationPool.begin(), fSimulationPool.end(), p); |
|
|
|
if( idx != fSimulationPool.kMissingIndex ) |
|
|
|
if (it != fSimulationPool.end()) |
|
|
|
fSimulationPool.Remove(idx); |
|
|
|
fSimulationPool.erase(it); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::IRemoveObject(plSceneObject* o) |
|
|
|
void plSceneNode::IRemoveObject(plSceneObject* o) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int idx = fSceneObjects.Find(o); |
|
|
|
auto it = std::find(fSceneObjects.begin(), fSceneObjects.end(), o); |
|
|
|
if( idx != fSceneObjects.kMissingIndex ) |
|
|
|
if (it != fSceneObjects.end()) |
|
|
|
fSceneObjects.Remove(idx); |
|
|
|
fSceneObjects.erase(it); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::IRemoveLight(plLightInfo* l) |
|
|
|
void plSceneNode::IRemoveLight(plLightInfo* l) |
|
|
|
{ |
|
|
|
{ |
|
|
|
hsAssert(l, "Removing nil light"); |
|
|
|
hsAssert(l, "Removing nil light"); |
|
|
|
|
|
|
|
|
|
|
|
int idx = fLightPool.Find(l); |
|
|
|
auto it = std::find(fLightPool.begin(), fLightPool.end(), l); |
|
|
|
if( idx != fLightPool.kMissingIndex ) |
|
|
|
if (it != fLightPool.end()) |
|
|
|
{ |
|
|
|
fLightPool.erase(it); |
|
|
|
fLightPool.Remove(idx); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::IRemoveOccluder(plOccluder* o) |
|
|
|
void plSceneNode::IRemoveOccluder(plOccluder* o) |
|
|
@ -369,9 +358,9 @@ void plSceneNode::IRemoveOccluder(plOccluder* o) |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::IRemoveGeneric(hsKeyedObject* k) |
|
|
|
void plSceneNode::IRemoveGeneric(hsKeyedObject* k) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int idx = fGenericPool.Find(k); |
|
|
|
auto it = std::find(fGenericPool.begin(), fGenericPool.end(), k); |
|
|
|
if( idx != fGenericPool.kMissingIndex ) |
|
|
|
if (it != fGenericPool.end()) |
|
|
|
fGenericPool.Remove(idx); |
|
|
|
fGenericPool.erase(it); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool plSceneNode::IOnRemove(plNodeRefMsg* refMsg) |
|
|
|
bool plSceneNode::IOnRemove(plNodeRefMsg* refMsg) |
|
|
@ -466,26 +455,24 @@ bool plSceneNode::MsgReceive(plMessage* msg) |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::ICleanUp( void ) |
|
|
|
void plSceneNode::ICleanUp( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Go find drawables to delete
|
|
|
|
/// Go find drawables to delete
|
|
|
|
for( i = 0; i < fDrawPool.GetCount(); i++ ) |
|
|
|
for (auto draw : fDrawPool) |
|
|
|
fDrawPool[ i ]->Optimize(); |
|
|
|
draw->Optimize(); |
|
|
|
|
|
|
|
|
|
|
|
if (fFilterGenerics) |
|
|
|
if (fFilterGenerics) |
|
|
|
{ |
|
|
|
{ |
|
|
|
for( i = fSceneObjects.GetCount() - 1; i >= 0; i--) |
|
|
|
ssize_t i; |
|
|
|
|
|
|
|
for ( i = fSceneObjects.size() - 1; i >= 0; i--) |
|
|
|
GetKey()->Release(fSceneObjects[i]->GetKey()); |
|
|
|
GetKey()->Release(fSceneObjects[i]->GetKey()); |
|
|
|
for( i = fDrawPool.GetCount() - 1; i >= 0; i--) |
|
|
|
for ( i = fDrawPool.size() - 1; i >= 0; i--) |
|
|
|
GetKey()->Release(fDrawPool[i]->GetKey()); |
|
|
|
GetKey()->Release(fDrawPool[i]->GetKey()); |
|
|
|
for( i = fSimulationPool.GetCount() - 1; i >= 0; i--) |
|
|
|
for ( i = fSimulationPool.size() - 1; i >= 0; i--) |
|
|
|
GetKey()->Release(fSimulationPool[i]->GetKey()); |
|
|
|
GetKey()->Release(fSimulationPool[i]->GetKey()); |
|
|
|
for( i = fAudioPool.GetCount() - 1; i >= 0; i--) |
|
|
|
for ( i = fAudioPool.size() - 1; i >= 0; i--) |
|
|
|
GetKey()->Release(fAudioPool[i]->GetKey()); |
|
|
|
GetKey()->Release(fAudioPool[i]->GetKey()); |
|
|
|
for ( i = fOccluders.GetCount() - 1; i >= 0; i--) |
|
|
|
for ( i = fOccluders.GetCount() - 1; i >= 0; i--) |
|
|
|
GetKey()->Release(fOccluders[i]->GetKey()); |
|
|
|
GetKey()->Release(fOccluders[i]->GetKey()); |
|
|
|
for( i = fLightPool.GetCount() - 1; i >= 0; i--) |
|
|
|
for ( i = fLightPool.size() - 1; i >= 0; i--) |
|
|
|
GetKey()->Release(fLightPool[i]->GetKey()); |
|
|
|
GetKey()->Release(fLightPool[i]->GetKey()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -497,16 +484,11 @@ void plSceneNode::ICleanUp( void ) |
|
|
|
|
|
|
|
|
|
|
|
plDrawable *plSceneNode::GetMatchingDrawable( const plDrawableCriteria& crit ) |
|
|
|
plDrawable *plSceneNode::GetMatchingDrawable( const plDrawableCriteria& crit ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
for (auto draw : fDrawPool) { |
|
|
|
|
|
|
|
if (draw->DoIMatch(crit)) |
|
|
|
|
|
|
|
return draw; |
|
|
|
for( i = 0; i < fDrawPool.GetCount(); i++ ) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if( fDrawPool[ i ]->DoIMatch( crit ) ) |
|
|
|
|
|
|
|
return fDrawPool[ i ]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return nullptr; |
|
|
|
return nil; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//// OptimizeDrawables ///////////////////////////////////////////////////////
|
|
|
|
//// OptimizeDrawables ///////////////////////////////////////////////////////
|
|
|
@ -515,10 +497,7 @@ plDrawable *plSceneNode::GetMatchingDrawable( const plDrawableCriteria& crit ) |
|
|
|
|
|
|
|
|
|
|
|
void plSceneNode::OptimizeDrawables( void ) |
|
|
|
void plSceneNode::OptimizeDrawables( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
for (auto draw : fDrawPool) |
|
|
|
|
|
|
|
draw->Optimize(); |
|
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < fDrawPool.GetCount(); i++ ) |
|
|
|
|
|
|
|
fDrawPool[ i ]->Optimize(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|