Skip to content

Commit 9f1d31b

Browse files
author
Haydelj
committed
refactored core
1 parent 78037d7 commit 9f1d31b

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

src/Interface/Modules/Render/ES/Core.cc

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ std::string ESCore::toString(std::string prefix) const
110110
return output;
111111
}
112112

113+
bool ESCore::hasGeomPromise()
114+
{
115+
for(auto& comp : mComponents)
116+
if(comp.second->getNumComponents() > 0)
117+
{
118+
if(mComponentIDNameMap.find(comp.first) != mComponentIDNameMap.end() &&
119+
mComponentIDNameMap.at(comp.first) == "ren:GeomPromise")
120+
return true;
121+
}
122+
return false;
123+
}
124+
113125
void ESCore::execute(double currentTime, double constantFrameTime)
114126
{
115127
++mCoreSequence;
@@ -148,22 +160,11 @@ void ESCore::execute(double currentTime, double constantFrameTime)
148160
renormalize(true);
149161
mSystems->renormalize();
150162

151-
// Perform garbage collection if requested.
163+
// Perform garbage collection if requested and safe
152164
if(runGC)
153165
{
154-
bool run = true;
155-
for(auto& comp : mComponents)
156-
if(comp.second->getNumComponents() > 0)
157-
{
158-
if(mComponentIDNameMap.find(comp.first) != mComponentIDNameMap.end() &&
159-
mComponentIDNameMap.at(comp.first) == "ren:GeomPromise")
160-
{
161-
run = false;
162-
break;
163-
}
164-
}
165-
if(run) runCompleteGC();
166-
else std::cout << "abourted GC\n";
166+
if(!hasGeomPromise())
167+
runCompleteGC();
167168
runGC = false;
168169
}
169170

src/Interface/Modules/Render/ES/Core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ namespace Render {
4949
void runGCOnNextExecution(){runGC = true;}
5050

5151
private:
52+
bool hasGeomPromise();
5253

5354
int64_t mCoreSequence; ///< Sequence number (frame) since start.
5455
spire::GLState mDefaultGLState; ///< Default OpenGL state.

src/Interface/Modules/Render/ES/SRInterface.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -834,11 +834,13 @@ namespace SCIRun {
834834

835835
DEBUG_LOG_LINE_INFO
836836

837-
if(!mCore.getStaticComponent<ren::StaticVBOMan>() ||
838-
!mCore.getStaticComponent<ren::StaticIBOMan>()) return;
837+
auto vmc = mCore.getStaticComponent<ren::StaticVBOMan>();
838+
auto imc = mCore.getStaticComponent<ren::StaticIBOMan>();
839+
if(!vmc || !imc) return;
839840

840-
std::weak_ptr<ren::VBOMan> vm = mCore.getStaticComponent<ren::StaticVBOMan>()->instance_;
841-
std::weak_ptr<ren::IBOMan> im = mCore.getStaticComponent<ren::StaticIBOMan>()->instance_;
841+
std::weak_ptr<ren::VBOMan> vm = vmc->instance_;
842+
std::weak_ptr<ren::IBOMan> im = imc->instance_;
843+
842844
if (std::shared_ptr<ren::VBOMan> vboMan = vm.lock())
843845
{
844846
DEBUG_LOG_LINE_INFO;

0 commit comments

Comments
 (0)