Refactoring: split items

This commit is contained in:
2025-12-27 16:05:32 +03:00
parent d3c93c5c18
commit 5bb529bc31
18 changed files with 2474 additions and 2206 deletions

View File

@@ -278,7 +278,7 @@ public:
float worldSize = terrain->getWorldSize();
float scaled = worldSize / (size - 1);
Ogre::Vector3 bodyPosition = terrain->getPosition();
// bodyPosition.y += (maxH + minH) / 2.0f;
// bodyPosition.y += (maxH + minH) / 2.0f;
bodyPosition.x += worldSize / 2.0f;
bodyPosition.z += worldSize / 2.0f;
Ogre::Vector3 offset =
@@ -338,21 +338,22 @@ public:
}
void update()
{
std::lock_guard<std::mutex> guard(mtx);
static bool created = false;
std::lock_guard<std::mutex> guard(mtx);
static bool created = false;
while (!collider_queue.empty()) {
Ogre::TerrainGroup *group =
Ogre::TerrainGroup *group =
collider_queue.front().group;
if (group->isDerivedDataUpdateInProgress())
break;
long x = collider_queue.front().x;
if (group->isDerivedDataUpdateInProgress())
break;
long x = collider_queue.front().x;
long y = collider_queue.front().y;
std::cout << x << " " << y << " "
<< collider_queue.size() << std::endl;
std::cout << x << " " << y << " "
<< collider_queue.size() << std::endl;
Ogre::Terrain *terrain = group->getTerrain(x, y);
Ogre::Vector3 worldPos;
group->convertTerrainSlotToWorldPosition(x, y,
&worldPos);
#if 0
std::cout << "terrain: " << terrain;
if (terrain)
std::cout
@@ -360,7 +361,8 @@ public:
<< terrain->isLoaded() << " "
<< terrain->isDerivedDataUpdateInProgress()
<< std::endl;
if (terrain && terrain->getHeightData() &&
#endif
if (terrain && terrain->getHeightData() &&
terrain->isLoaded() &&
!terrain->isDerivedDataUpdateInProgress()) {
Ogre::LogManager::getSingleton().logError(
@@ -368,8 +370,8 @@ public:
Ogre::StringConverter::toString(x) +
" " +
Ogre::StringConverter::toString(y));
// float minH = terrain->getMinHeight();
// float maxH = terrain->getMaxHeight();
// float minH = terrain->getMinHeight();
// float maxH = terrain->getMaxHeight();
int size = terrain->getSize();
float worldSize = terrain->getWorldSize();
{
@@ -440,22 +442,22 @@ public:
#endif
/* Spawn items */
StaticGeometryModule::addGeometryForSlot(x, y);
collider_queue.pop_front();
collider_queue.pop_front();
} else {
/* Terrain data not ready maybe move to next terrain */
gen_collider m = collider_queue.front();
/* Terrain data not ready maybe move to next terrain */
gen_collider m = collider_queue.front();
collider_queue.pop_front();
collider_queue.push_back(m);
break; // allow system to move on
collider_queue.push_back(m);
break; // allow system to move on
}
}
if (collider_queue.empty() &&
!ECS::get<Terrain>().mTerrainReady) {
ECS::get_mut<Terrain>().mTerrainReady = true;
ECS::modified<Terrain>();
}
}
}
if (collider_queue.empty() &&
!ECS::get<Terrain>().mTerrainReady) {
ECS::get_mut<Terrain>().mTerrainReady = true;
ECS::modified<Terrain>();
}
}
};
class DummyPageProvider : public Ogre::PageProvider {
public: