Fix exception when number of primitive sets not what assumed.

This was something that happened when random vegetation was off, but tree shadows was on.

Adding random vegetation would then reliably cause an exception.
This commit is contained in:
Richard Harrison
2018-10-30 20:13:32 +01:00
parent 758ab5e581
commit 61cc8d6c50

View File

@@ -233,9 +233,11 @@ void addTreeToLeafGeode(Geode* geode, const SGVec3f& p, const SGVec3f& t)
int imax = 2;
if (use_tree_shadows) { imax = 3; }
for (int i = 0; i < imax; ++i) {
DrawArrays* primSet = static_cast<DrawArrays*>(geom->getPrimitiveSet(i));
if(primSet != nullptr)
primSet->setCount(numVerts);
if (i < geom->getNumPrimitiveSets()) {
DrawArrays* primSet = static_cast<DrawArrays*>(geom->getPrimitiveSet(i));
if (primSet != nullptr)
primSet->setCount(numVerts);
}
}
}
}