Action nodes support and lots of other updates
This commit is contained in:
@@ -4,7 +4,7 @@ find_package(Bullet REQUIRED)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
find_package(OgreProcedural REQUIRED CONFIG)
|
||||
add_library(items STATIC items.cpp harbour.cpp temple.cpp town.cpp)
|
||||
target_include_directories(items PUBLIC .)
|
||||
target_include_directories(items PUBLIC . ${CMAKE_SOURCE_DIR}/src/FastNoiseLite)
|
||||
target_link_libraries(items PRIVATE
|
||||
flecs::flecs_static
|
||||
nlohmann_json::nlohmann_json
|
||||
@@ -13,4 +13,4 @@ target_link_libraries(items PRIVATE
|
||||
OgreBites
|
||||
editor
|
||||
physics
|
||||
)
|
||||
)
|
||||
|
||||
@@ -22,6 +22,22 @@ namespace ECS
|
||||
{
|
||||
namespace Items
|
||||
{
|
||||
void runScriptsForAllTowns()
|
||||
{
|
||||
std::pair<flecs::entity, Ogre::String> selected_item;
|
||||
std::list<std::pair<flecs::entity, Ogre::String> > items;
|
||||
StaticGeometryModule::getItemsProperties(&items);
|
||||
for (const auto &item : items) {
|
||||
nlohmann::json j = nlohmann::json::parse(item.second);
|
||||
Ogre::String itemType = j["type"].get<Ogre::String>();
|
||||
if (itemType == "town") {
|
||||
Items::runAllScriptsForTown(item.first);
|
||||
if (item.first.has<TerrainItemNode>())
|
||||
Geometry::updateItemGeometry(item.first);
|
||||
}
|
||||
}
|
||||
StaticGeometryModule::saveItems();
|
||||
}
|
||||
void showItemPopup(const std::pair<flecs::entity, Ogre::String> &item)
|
||||
{
|
||||
Ogre::String popupLabel =
|
||||
@@ -131,8 +147,7 @@ void showItemPopup(const std::pair<flecs::entity, Ogre::String> &item)
|
||||
orientation;
|
||||
item.first.modified<TerrainItem>();
|
||||
StaticGeometryModule::saveItems();
|
||||
StaticGeometryModule::destroyItemGeometry(item.first);
|
||||
StaticGeometryModule::createItemGeometry(item.first);
|
||||
StaticGeometryModule::updateItemGeometry(item.first);
|
||||
}
|
||||
if (itemType == "harbour")
|
||||
createHarbourPopup(item);
|
||||
@@ -194,6 +209,7 @@ namespace Geometry
|
||||
{
|
||||
void setupLods(Ogre::LodConfig &config)
|
||||
{
|
||||
int count = 0;
|
||||
// config.advanced.useCompression = false;
|
||||
config.advanced.useVertexNormals = true;
|
||||
config.advanced.preventPunchingHoles = true;
|
||||
@@ -204,7 +220,28 @@ void setupLods(Ogre::LodConfig &config)
|
||||
// config.createGeneratedLodLevel(200, 0.50f);
|
||||
config.createGeneratedLodLevel(500, 0.85f);
|
||||
config.advanced.useBackgroundQueue = false;
|
||||
Ogre::MeshLodGenerator::getSingleton().generateLodLevels(config);
|
||||
std::cout << "mesh name: " << config.mesh->getName() << std::endl;
|
||||
bool crash = false;
|
||||
for (count = 0; count < config.mesh->getSubMeshes().size(); count++) {
|
||||
Ogre::SubMesh *submesh = config.mesh->getSubMeshes()[count];
|
||||
std::cout << "unprocessed submesh: " << count << " " << submesh
|
||||
<< std::endl;
|
||||
if (submesh)
|
||||
submesh->parent = config.mesh.get();
|
||||
else
|
||||
crash = true;
|
||||
}
|
||||
Ogre::MeshLodGenerator::getSingleton().generateLodLevels(config);
|
||||
for (count = 0; count < config.mesh->getSubMeshes().size(); count++) {
|
||||
Ogre::SubMesh *submesh = config.mesh->getSubMeshes()[count];
|
||||
std::cout << "submesh: " << count << " " << submesh
|
||||
<< std::endl;
|
||||
if (submesh)
|
||||
submesh->parent = config.mesh.get();
|
||||
else
|
||||
crash = true;
|
||||
}
|
||||
OgreAssert(!crash, "no submesh");
|
||||
}
|
||||
|
||||
Ogre::StaticGeometry *createStaticGeometry(flecs::entity e)
|
||||
@@ -294,6 +331,14 @@ void destroyItemGeometry(flecs::entity e)
|
||||
#endif
|
||||
e.remove<TerrainItemNode>();
|
||||
}
|
||||
void updateItemGeometry(flecs::entity e)
|
||||
{
|
||||
OgreAssert(e.has<TerrainItem>(), "not terrain item");
|
||||
if (e.has<TerrainItemNode>())
|
||||
destroyItemGeometry(e);
|
||||
createItemGeometry(e);
|
||||
}
|
||||
|
||||
flecs::entity createMeshGeometry(const Ogre::String &meshName,
|
||||
flecs::entity parente,
|
||||
Ogre::SceneNode *sceneNode,
|
||||
@@ -322,7 +367,7 @@ flecs::entity createMeshGeometry(const Ogre::String &meshName,
|
||||
.set<TerrainItemMeshNode>({ sceneNode, geo });
|
||||
JoltPhysicsWrapper::getSingleton().addBody(id,
|
||||
JPH::EActivation::Activate);
|
||||
return e;
|
||||
return e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace Items
|
||||
void showItemPopup(const std::pair<flecs::entity, Ogre::String> &item);
|
||||
void showItemButtons(const std::pair<flecs::entity, Ogre::String> &item);
|
||||
void createItemsMenu();
|
||||
void runScriptsForAllTowns();
|
||||
}
|
||||
namespace Geometry
|
||||
{
|
||||
@@ -53,6 +54,7 @@ struct harbourMaker {
|
||||
};
|
||||
void createItemGeometry(flecs::entity e);
|
||||
void destroyItemGeometry(flecs::entity e);
|
||||
void updateItemGeometry(flecs::entity e);
|
||||
flecs::entity createMeshGeometry(const Ogre::String &meshName,
|
||||
flecs::entity parente,
|
||||
Ogre::SceneNode *sceneNode,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,25 +12,15 @@ namespace Items
|
||||
void createTownItem();
|
||||
void createTownMenu();
|
||||
void createTownPopup(const std::pair<flecs::entity, Ogre::String> item);
|
||||
void runAllScriptsForTown(flecs::entity e);
|
||||
}
|
||||
namespace Geometry
|
||||
{
|
||||
void clampUV(flecs::entity e, Procedural::TriangleBuffer &tb,
|
||||
const Ogre::String &rectKey);
|
||||
Ogre::MaterialPtr createTownMaterial(flecs::entity e, bool force = false);
|
||||
void createCells(flecs::entity e, const nlohmann::json &jdistrict, int index,
|
||||
Ogre::SceneNode *sceneNode, Ogre::StaticGeometry *geo);
|
||||
void createTown(flecs::entity e, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo);
|
||||
void createTownPlazza(flecs::entity e, const nlohmann::json &jdistrict,
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo);
|
||||
void createTownLots(flecs::entity e, const nlohmann::json &jdistrict,
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo);
|
||||
void createTownRoofs(flecs::entity e, const nlohmann::json &jdistrict,
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user