Adapted more debugging with Tracy, characters update
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "StaticGeometryModule.h"
|
||||
#include "items.h"
|
||||
#include "harbour.h"
|
||||
#include <tracy/Tracy.hpp>
|
||||
namespace ECS
|
||||
{
|
||||
namespace Items
|
||||
@@ -19,6 +20,7 @@ namespace Items
|
||||
/* This is editor function */
|
||||
static bool findPierOffset(float &offset)
|
||||
{
|
||||
ZoneScoped;
|
||||
Ogre::Vector3 basePos =
|
||||
ECS::get<EditorGizmo>().sceneNode->_getDerivedPosition();
|
||||
Ogre::Quaternion baseRot =
|
||||
@@ -41,7 +43,8 @@ static bool findPierOffset(float &offset)
|
||||
static bool findPierOffsetAndLengthAndDepth(float &offset, float &length,
|
||||
float &depth)
|
||||
{
|
||||
if (!findPierOffset(offset))
|
||||
ZoneScoped;
|
||||
if (!findPierOffset(offset))
|
||||
return false;
|
||||
Ogre::Vector3 basePos =
|
||||
ECS::get<EditorGizmo>().sceneNode->_getDerivedPosition();
|
||||
@@ -66,7 +69,8 @@ static bool findPierOffsetAndLengthAndDepth(float &offset, float &length,
|
||||
}
|
||||
static void findPierHeight(float maxLength, float &height)
|
||||
{
|
||||
Ogre::Vector3 basePos =
|
||||
ZoneScoped;
|
||||
Ogre::Vector3 basePos =
|
||||
ECS::get<EditorGizmo>().sceneNode->_getDerivedPosition();
|
||||
Ogre::Quaternion baseRot =
|
||||
ECS::get<EditorGizmo>().sceneNode->_getDerivedOrientation();
|
||||
@@ -86,7 +90,8 @@ static void findPierHeight(float maxLength, float &height)
|
||||
}
|
||||
static void findPierPath(float pathLength, std::vector<Ogre::Vector3> &path)
|
||||
{
|
||||
float minHeight = 0.2f;
|
||||
ZoneScoped;
|
||||
float minHeight = 0.2f;
|
||||
int i;
|
||||
Ogre::Vector3 basePos =
|
||||
ECS::get<EditorGizmo>().sceneNode->_getDerivedPosition();
|
||||
@@ -146,7 +151,8 @@ static void findPierPath(float pathLength, std::vector<Ogre::Vector3> &path)
|
||||
}
|
||||
bool editHarbourDistrict(nlohmann::json &jitem)
|
||||
{
|
||||
float plazzaRadius = 5.0f;
|
||||
ZoneScoped;
|
||||
float plazzaRadius = 5.0f;
|
||||
float plazzaHeight = 0.2f;
|
||||
float plazzaElevation = 0.0f;
|
||||
float centerOffset = 0.0f;
|
||||
@@ -280,7 +286,8 @@ bool editHarbourDistrict(nlohmann::json &jitem)
|
||||
}
|
||||
void createHarbourPopup(const std::pair<flecs::entity, Ogre::String> item)
|
||||
{
|
||||
bool lighthouse = false;
|
||||
ZoneScoped;
|
||||
bool lighthouse = false;
|
||||
float lighthouseDistance = 0.0f;
|
||||
float lighthouseAngle = 0.0f;
|
||||
float centerOffset = 0.0f;
|
||||
@@ -328,7 +335,8 @@ void createHarbourPopup(const std::pair<flecs::entity, Ogre::String> item)
|
||||
}
|
||||
void createHarbourItem()
|
||||
{
|
||||
Ogre::Vector3 itemPosition =
|
||||
ZoneScoped;
|
||||
Ogre::Vector3 itemPosition =
|
||||
ECS::get<EditorGizmo>().sceneNode->_getDerivedPosition();
|
||||
Ogre::Quaternion itemOrientation =
|
||||
ECS::get<EditorGizmo>().sceneNode->_getDerivedOrientation();
|
||||
@@ -364,7 +372,8 @@ void createHarbourItem()
|
||||
}
|
||||
void createHarbourMenu()
|
||||
{
|
||||
if (ImGui::MenuItem("Create"))
|
||||
ZoneScoped;
|
||||
if (ImGui::MenuItem("Create"))
|
||||
createHarbourItem();
|
||||
}
|
||||
}
|
||||
@@ -373,7 +382,8 @@ namespace Geometry
|
||||
void createBridge(flecs::entity e, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
int i;
|
||||
ZoneScoped;
|
||||
int i;
|
||||
Procedural::TriangleBuffer tb;
|
||||
Ogre::MaterialPtr harbourMaterial;
|
||||
harbourMaterial = Ogre::MaterialManager::getSingleton().getByName(
|
||||
@@ -545,7 +555,8 @@ void createBridge(flecs::entity e, Ogre::SceneNode *sceneNode,
|
||||
void createPier(flecs::entity e, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
Ogre::MaterialPtr harbourMaterial;
|
||||
ZoneScoped;
|
||||
Ogre::MaterialPtr harbourMaterial;
|
||||
harbourMaterial = Ogre::MaterialManager::getSingleton().getByName(
|
||||
"proceduralMaterialHarbour" +
|
||||
Ogre::StringConverter::toString(e.id()));
|
||||
@@ -705,7 +716,8 @@ void createPier(flecs::entity e, Ogre::SceneNode *sceneNode,
|
||||
void createPlazza(flecs::entity e, const nlohmann::json &district,
|
||||
Ogre::SceneNode *sceneNode, Ogre::StaticGeometry *geo)
|
||||
{
|
||||
Ogre::MaterialPtr harbourMaterial;
|
||||
ZoneScoped;
|
||||
Ogre::MaterialPtr harbourMaterial;
|
||||
harbourMaterial = Ogre::MaterialManager::getSingleton().getByName(
|
||||
"proceduralMaterialHarbour" +
|
||||
Ogre::StringConverter::toString(e.id()));
|
||||
@@ -784,7 +796,8 @@ void createPlazza(flecs::entity e, const nlohmann::json &district,
|
||||
void createBuildings(flecs::entity e, const nlohmann::json &district,
|
||||
Ogre::SceneNode *sceneNode, Ogre::StaticGeometry *geo)
|
||||
{
|
||||
Ogre::MaterialPtr harbourMaterial;
|
||||
ZoneScoped;
|
||||
Ogre::MaterialPtr harbourMaterial;
|
||||
harbourMaterial = Ogre::MaterialManager::getSingleton().getByName(
|
||||
"proceduralMaterialHarbour" +
|
||||
Ogre::StringConverter::toString(e.id()));
|
||||
@@ -865,7 +878,8 @@ void createBuildings(flecs::entity e, const nlohmann::json &district,
|
||||
void createHarbour(flecs::entity e, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
std::cout << "createHarbour " << e.id() << std::endl;
|
||||
ZoneScoped;
|
||||
std::cout << "createHarbour " << e.id() << std::endl;
|
||||
Ogre::MaterialPtr harbourMaterial;
|
||||
harbourMaterial = Ogre::MaterialManager::getSingleton().getByName(
|
||||
"proceduralMaterialHarbour" +
|
||||
@@ -980,4 +994,4 @@ void createHarbour(flecs::entity e, Ogre::SceneNode *sceneNode,
|
||||
geo->build();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
#include "temple.h"
|
||||
#include "town.h"
|
||||
#include "items.h"
|
||||
#include <tracy/Tracy.hpp>
|
||||
namespace ECS
|
||||
{
|
||||
namespace Items
|
||||
{
|
||||
void runScriptsForAllTowns()
|
||||
{
|
||||
ZoneScoped;
|
||||
std::pair<flecs::entity, Ogre::String> selected_item;
|
||||
std::list<std::pair<flecs::entity, Ogre::String> > items;
|
||||
StaticGeometryModule::getItemsProperties(&items);
|
||||
@@ -40,7 +42,8 @@ void runScriptsForAllTowns()
|
||||
}
|
||||
void showItemPopup(const std::pair<flecs::entity, Ogre::String> &item)
|
||||
{
|
||||
Ogre::String popupLabel =
|
||||
ZoneScoped;
|
||||
Ogre::String popupLabel =
|
||||
"EditPopup" + Ogre::StringConverter::toString(item.first.id());
|
||||
if (ImGui::BeginPopup(popupLabel.c_str())) {
|
||||
Ogre::String prop =
|
||||
@@ -160,7 +163,8 @@ void showItemPopup(const std::pair<flecs::entity, Ogre::String> &item)
|
||||
}
|
||||
void showItemButtons(const std::pair<flecs::entity, Ogre::String> &item)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
ZoneScoped;
|
||||
ImGui::SameLine();
|
||||
Ogre::String upd_label =
|
||||
"Update Height##" +
|
||||
Ogre::StringConverter::toString(item.first.id());
|
||||
@@ -190,7 +194,8 @@ void showItemButtons(const std::pair<flecs::entity, Ogre::String> &item)
|
||||
}
|
||||
void createItemsMenu()
|
||||
{
|
||||
if (ImGui::BeginMenu("Harbour")) {
|
||||
ZoneScoped;
|
||||
if (ImGui::BeginMenu("Harbour")) {
|
||||
Items::createHarbourMenu();
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
@@ -209,6 +214,7 @@ namespace Geometry
|
||||
{
|
||||
void setupLods(Ogre::LodConfig &config)
|
||||
{
|
||||
ZoneScoped;
|
||||
int count = 0;
|
||||
// config.advanced.useCompression = false;
|
||||
config.advanced.useVertexNormals = true;
|
||||
@@ -246,7 +252,8 @@ void setupLods(Ogre::LodConfig &config)
|
||||
|
||||
Ogre::StaticGeometry *createStaticGeometry(flecs::entity e)
|
||||
{
|
||||
Ogre::String props = e.get<TerrainItem>().properties;
|
||||
ZoneScoped;
|
||||
Ogre::String props = e.get<TerrainItem>().properties;
|
||||
nlohmann::json jp = nlohmann::json::parse(props);
|
||||
if (jp.find("type") != jp.end()) {
|
||||
Ogre::String itemType = jp["type"].get<Ogre::String>();
|
||||
@@ -264,7 +271,8 @@ Ogre::StaticGeometry *createStaticGeometry(flecs::entity e)
|
||||
}
|
||||
void createItemGeometry(flecs::entity e)
|
||||
{
|
||||
OgreAssert(!e.has<TerrainItemNode>(), "Geometry already created");
|
||||
ZoneScoped;
|
||||
OgreAssert(!e.has<TerrainItemNode>(), "Geometry already created");
|
||||
std::cout << "creating geometry for item: " << e.id() << std::endl;
|
||||
Ogre::String props = e.get<TerrainItem>().properties;
|
||||
nlohmann::json jp = nlohmann::json::parse(props);
|
||||
@@ -322,7 +330,8 @@ void createItemGeometry(flecs::entity e)
|
||||
|
||||
void destroyItemGeometry(flecs::entity e)
|
||||
{
|
||||
OgreAssert(e.has<TerrainItemNode>(), "No geometry created");
|
||||
ZoneScoped;
|
||||
OgreAssert(e.has<TerrainItemNode>(), "No geometry created");
|
||||
#if 0
|
||||
ECS::get<EngineData>().mScnMgr->destroyStaticGeometry()
|
||||
e.get<TerrainItemNode>().geo->destroy();
|
||||
@@ -333,6 +342,7 @@ void destroyItemGeometry(flecs::entity e)
|
||||
}
|
||||
void updateItemGeometry(flecs::entity e)
|
||||
{
|
||||
ZoneScoped;
|
||||
OgreAssert(e.has<TerrainItem>(), "not terrain item");
|
||||
if (e.has<TerrainItemNode>())
|
||||
destroyItemGeometry(e);
|
||||
@@ -344,7 +354,8 @@ flecs::entity createMeshGeometry(const Ogre::String &meshName,
|
||||
Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().load(
|
||||
ZoneScoped;
|
||||
Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().load(
|
||||
meshName,
|
||||
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
|
||||
OgreAssert(mesh, "mesh " + meshName + " not found");
|
||||
|
||||
@@ -14,12 +14,14 @@
|
||||
#include "PhysicsModule.h"
|
||||
#include "items.h"
|
||||
#include "temple.h"
|
||||
#include <tracy/Tracy.hpp>
|
||||
namespace ECS
|
||||
{
|
||||
namespace Items
|
||||
{
|
||||
void createTempleItem()
|
||||
{
|
||||
ZoneScoped;
|
||||
Ogre::Vector3 itemPosition =
|
||||
ECS::get<EditorGizmo>().sceneNode->_getDerivedPosition();
|
||||
Ogre::Quaternion itemOrientation =
|
||||
@@ -38,12 +40,14 @@ void createTempleItem()
|
||||
}
|
||||
void createTempleMenu()
|
||||
{
|
||||
if (ImGui::MenuItem("Create"))
|
||||
ZoneScoped;
|
||||
if (ImGui::MenuItem("Create"))
|
||||
createTempleItem();
|
||||
}
|
||||
void createTemplePopup(const std::pair<flecs::entity, Ogre::String> item)
|
||||
{
|
||||
float size = 40.0f;
|
||||
ZoneScoped;
|
||||
float size = 40.0f;
|
||||
float pillarRadius = 0.5f;
|
||||
float pillarHeight = 16.0f;
|
||||
int pillarCount = 20;
|
||||
@@ -88,7 +92,8 @@ namespace Geometry
|
||||
void createTemple(flecs::entity e, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
Ogre::String props = e.get<TerrainItem>().properties;
|
||||
ZoneScoped;
|
||||
Ogre::String props = e.get<TerrainItem>().properties;
|
||||
nlohmann::json jp = nlohmann::json::parse(props);
|
||||
float size = 20.0f;
|
||||
int pillarCount = 4;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
void serializeMesh(Ogre::MeshPtr mesh, const Ogre::String &meshName)
|
||||
{
|
||||
ZoneScoped;
|
||||
Ogre::MeshSerializer meshSerializer;
|
||||
|
||||
meshSerializer.exportMesh(mesh, meshName,
|
||||
@@ -44,12 +45,14 @@ namespace Items
|
||||
{
|
||||
int64_t makeCellKey(int kx, int ky, int kz)
|
||||
{
|
||||
ZoneScoped;
|
||||
int64_t key =
|
||||
(int64_t)kx + 1024 * (int64_t)ky + 1024 * 1024 * (int64_t)kz;
|
||||
return key;
|
||||
}
|
||||
int64_t makeCellKey(const nlohmann::json &cell)
|
||||
{
|
||||
ZoneScoped;
|
||||
int64_t kx = cell["x"].get<int>();
|
||||
int64_t ky = cell["y"].get<int>();
|
||||
int64_t kz = cell["z"].get<int>();
|
||||
@@ -60,6 +63,7 @@ void displayGrid(flecs::entity e, nlohmann::json &lot, int index,
|
||||
Ogre::SceneNode *sceneNode, const Ogre::Vector3 &localPosition,
|
||||
const Ogre::Quaternion &localRotation)
|
||||
{
|
||||
ZoneScoped;
|
||||
if (lot.find("edited") == lot.end()) {
|
||||
lot["edited"] = true;
|
||||
int width = lot["width"].get<int>();
|
||||
@@ -100,7 +104,8 @@ void displayGrid(flecs::entity e, nlohmann::json &lot, int index,
|
||||
}
|
||||
void createTownItem()
|
||||
{
|
||||
Ogre::Vector3 itemPosition =
|
||||
ZoneScoped;
|
||||
Ogre::Vector3 itemPosition =
|
||||
ECS::get<EditorGizmo>().sceneNode->_getDerivedPosition();
|
||||
Ogre::Quaternion itemOrientation =
|
||||
ECS::get<EditorGizmo>().sceneNode->_getDerivedOrientation();
|
||||
@@ -114,11 +119,13 @@ void createTownItem()
|
||||
}
|
||||
void createTownMenu()
|
||||
{
|
||||
if (ImGui::MenuItem("Create"))
|
||||
ZoneScoped;
|
||||
if (ImGui::MenuItem("Create"))
|
||||
createTownItem();
|
||||
}
|
||||
bool editCell(const Ogre::String &cellLabel, nlohmann::json &cell)
|
||||
{
|
||||
ZoneScoped;
|
||||
bool changed = false;
|
||||
auto checkboxBit = [cellLabel, &changed](Ogre::String label,
|
||||
nlohmann::json &cell,
|
||||
@@ -191,6 +198,7 @@ struct CellsScript {
|
||||
, cells(lot["cells"])
|
||||
, fucells(lot["furniture_cells"])
|
||||
{
|
||||
ZoneScoped;
|
||||
noise.SetNoiseType(FastNoiseLite::NoiseType_OpenSimplex2);
|
||||
noise.SetSeed(310);
|
||||
noise.SetFrequency(0.01f);
|
||||
@@ -485,6 +493,7 @@ struct CellsScript {
|
||||
}
|
||||
static std::string trim(const std::string &str)
|
||||
{
|
||||
ZoneScoped;
|
||||
// Find the first character that is not a whitespace character
|
||||
const std::string ws =
|
||||
" \t\n\r\f\v"; // Common whitespace characters
|
||||
@@ -504,6 +513,7 @@ struct CellsScript {
|
||||
static std::vector<std::string> split_and_trim(const std::string &s,
|
||||
char delimiter)
|
||||
{
|
||||
ZoneScoped;
|
||||
std::vector<std::string> tokens;
|
||||
std::string token;
|
||||
std::stringstream ss(s); // Use stringstream to parse the string
|
||||
@@ -521,16 +531,19 @@ struct CellsScript {
|
||||
}
|
||||
void buildCellIndex()
|
||||
{
|
||||
ZoneScoped;
|
||||
for (auto &cell : cells)
|
||||
cell["id"] = makeCellKey(cell);
|
||||
}
|
||||
void buildFCellIndex()
|
||||
{
|
||||
ZoneScoped;
|
||||
for (auto &fucell : fucells)
|
||||
fucell["id"] = makeCellKey(fucell);
|
||||
}
|
||||
int findCell(int X, int Y, int Z)
|
||||
{
|
||||
ZoneScoped;
|
||||
int64_t key = makeCellKey(X, Y, Z);
|
||||
int result = -1;
|
||||
int i;
|
||||
@@ -545,6 +558,7 @@ struct CellsScript {
|
||||
}
|
||||
int findFCell(int X, int Y, int Z)
|
||||
{
|
||||
ZoneScoped;
|
||||
int64_t key = makeCellKey(X, Y, Z);
|
||||
int result = -1;
|
||||
int i;
|
||||
@@ -559,6 +573,7 @@ struct CellsScript {
|
||||
}
|
||||
void bitCmd(const Ogre::String &cmd, const Ogre::String &bit)
|
||||
{
|
||||
ZoneScoped;
|
||||
uint64_t flags = 0;
|
||||
std::vector<Ogre::String> bitconv = {
|
||||
"floor", "ceiling", "wallx-", "wallx+",
|
||||
@@ -590,6 +605,7 @@ struct CellsScript {
|
||||
}
|
||||
bool isBit(const Ogre::String &bit)
|
||||
{
|
||||
ZoneScoped;
|
||||
uint64_t flags = 0;
|
||||
std::vector<Ogre::String> bitconv = {
|
||||
"floor", "ceiling", "wallx-", "wallx+",
|
||||
@@ -617,6 +633,7 @@ struct CellsScript {
|
||||
}
|
||||
static bool isBit(const nlohmann::json &cell, const Ogre::String &bit)
|
||||
{
|
||||
ZoneScoped;
|
||||
uint64_t flags = 0;
|
||||
std::vector<Ogre::String> bitconv = {
|
||||
"floor", "ceiling", "wallx-", "wallx+",
|
||||
@@ -642,6 +659,7 @@ struct CellsScript {
|
||||
}
|
||||
void cell(uint64_t flags)
|
||||
{
|
||||
ZoneScoped;
|
||||
if (findCell(currentX, currentY, currentZ) == -1) {
|
||||
nlohmann::json cell;
|
||||
buildCellIndex();
|
||||
@@ -659,12 +677,14 @@ struct CellsScript {
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
ZoneScoped;
|
||||
int index = findCell(currentX, currentY, currentZ);
|
||||
if (index >= 0)
|
||||
cells.erase(index);
|
||||
}
|
||||
void clear_area(int minX, int minZ, int sizeX, int sizeZ)
|
||||
{
|
||||
ZoneScoped;
|
||||
int i, j;
|
||||
for (i = 0; i < sizeZ; i++)
|
||||
for (j = 0; j < sizeX; j++) {
|
||||
@@ -675,12 +695,14 @@ struct CellsScript {
|
||||
}
|
||||
void clear_furniture()
|
||||
{
|
||||
ZoneScoped;
|
||||
int index = findFCell(currentX, currentY, currentZ);
|
||||
if (index >= 0)
|
||||
fucells.erase(index);
|
||||
}
|
||||
void clear_furniture_area(int minX, int minZ, int sizeX, int sizeZ)
|
||||
{
|
||||
ZoneScoped;
|
||||
int i, j;
|
||||
for (i = 0; i < sizeZ; i++)
|
||||
for (j = 0; j < sizeX; j++) {
|
||||
@@ -691,6 +713,7 @@ struct CellsScript {
|
||||
}
|
||||
int room(int minX, int minZ, int sizeX, int sizeZ)
|
||||
{
|
||||
ZoneScoped;
|
||||
int i, j, ret;
|
||||
clear_area(minX, minZ, sizeX, sizeZ);
|
||||
for (i = 0; i < sizeZ; i++)
|
||||
@@ -726,6 +749,7 @@ struct CellsScript {
|
||||
int roof(int minX, int minZ, int sizeX, int sizeZ, float height,
|
||||
int type)
|
||||
{
|
||||
ZoneScoped;
|
||||
nlohmann::json roofs = nlohmann::json::array();
|
||||
if (lot.find("roofs") != lot.end())
|
||||
roofs = lot["roofs"];
|
||||
@@ -748,11 +772,13 @@ struct CellsScript {
|
||||
}
|
||||
void clear_roofs()
|
||||
{
|
||||
ZoneScoped;
|
||||
lot["roofs"] = nlohmann::json::array();
|
||||
}
|
||||
void fcell(const std::vector<Ogre::String> &tags,
|
||||
nlohmann::json furniture, int rotation)
|
||||
{
|
||||
ZoneScoped;
|
||||
nlohmann::json jtags = nlohmann::json::array();
|
||||
for (const auto &tag : tags)
|
||||
jtags.push_back(tag);
|
||||
@@ -779,6 +805,7 @@ struct CellsScript {
|
||||
nlohmann::json select_furniture(const std::vector<Ogre::String> &tags,
|
||||
const std::vector<Ogre::String> ¬ags)
|
||||
{
|
||||
ZoneScoped;
|
||||
nlohmann::json adata = nlohmann::json::array();
|
||||
ECS::get().query_builder<const FurnitureItem>().build().each(
|
||||
[&](flecs::entity e, const FurnitureItem &item) {
|
||||
@@ -827,6 +854,7 @@ struct CellsScript {
|
||||
}
|
||||
bool place_furniture(int room, Ogre::String tags)
|
||||
{
|
||||
ZoneScoped;
|
||||
bool ret = true;
|
||||
std::vector<Ogre::String> atags = split_and_trim(tags, ',');
|
||||
int i, j;
|
||||
@@ -1026,6 +1054,7 @@ struct CellsScript {
|
||||
|
||||
std::vector<std::pair<int, int> > roomEdge(int room)
|
||||
{
|
||||
ZoneScoped;
|
||||
std::vector<std::pair<int, int> > seg;
|
||||
std::set<std::pair<int, int> > seen;
|
||||
int i;
|
||||
@@ -1076,12 +1105,14 @@ out:
|
||||
}
|
||||
bool adjacent(std::pair<int, int> c1, std::pair<int, int> c2)
|
||||
{
|
||||
ZoneScoped;
|
||||
int dx = std::abs(c1.first - c2.first);
|
||||
int dz = std::abs(c1.second - c2.second);
|
||||
return (dx == 0 && dz == 1) || (dx == 1 && dz == 0);
|
||||
}
|
||||
void dumpSeg(const std::vector<std::pair<int, int> > &seg)
|
||||
{
|
||||
ZoneScoped;
|
||||
int count = 0;
|
||||
for (auto &cell : seg) {
|
||||
std::cout << count << " " << cell.first << " "
|
||||
@@ -1093,6 +1124,7 @@ out:
|
||||
std::vector<std::pair<int, int> > &ret1,
|
||||
std::vector<std::pair<int, int> > &ret2)
|
||||
{
|
||||
ZoneScoped;
|
||||
std::vector<std::pair<int, int> > room_seg = roomEdge(room);
|
||||
std::vector<std::pair<int, int> > other_seg = roomEdge(other);
|
||||
std::vector<std::pair<int, int> > ret;
|
||||
@@ -1110,6 +1142,7 @@ out:
|
||||
}
|
||||
void createExit0(int room)
|
||||
{
|
||||
ZoneScoped;
|
||||
int posX = rooms[room].minX;
|
||||
int posZ = rooms[room].minZ;
|
||||
int i;
|
||||
@@ -1138,6 +1171,7 @@ out:
|
||||
}
|
||||
void createExit1(int room)
|
||||
{
|
||||
ZoneScoped;
|
||||
int posX = rooms[room].minX;
|
||||
int posZ = rooms[room].minZ + rooms[room].sizeZ - 1;
|
||||
int i;
|
||||
@@ -1166,6 +1200,7 @@ out:
|
||||
}
|
||||
void createExit2(int room)
|
||||
{
|
||||
ZoneScoped;
|
||||
int posX = rooms[room].minX + rooms[room].sizeX - 1;
|
||||
int posZ = rooms[room].minZ;
|
||||
int i;
|
||||
@@ -1194,6 +1229,7 @@ out:
|
||||
}
|
||||
void createExit3(int room)
|
||||
{
|
||||
ZoneScoped;
|
||||
int posX = rooms[room].minX;
|
||||
int posZ = rooms[room].minZ;
|
||||
int i;
|
||||
@@ -1222,6 +1258,7 @@ out:
|
||||
}
|
||||
void createWindows(int room)
|
||||
{
|
||||
ZoneScoped;
|
||||
int posX = rooms[room].minX;
|
||||
int posZ = rooms[room].minZ;
|
||||
int i;
|
||||
@@ -1274,6 +1311,7 @@ out:
|
||||
}
|
||||
void createExterior()
|
||||
{
|
||||
ZoneScoped;
|
||||
int room;
|
||||
for (room = 0; room < rooms.size(); room++) {
|
||||
int posX = rooms[room].minX;
|
||||
@@ -1341,6 +1379,7 @@ out:
|
||||
}
|
||||
void connectRooms(int r1, int r2)
|
||||
{
|
||||
ZoneScoped;
|
||||
std::vector<std::pair<int, int> > seg1, seg2;
|
||||
int index = 0;
|
||||
adjacentCells(r1, r2, seg1, seg2);
|
||||
@@ -1460,10 +1499,12 @@ out:
|
||||
}
|
||||
virtual ~CellsScript()
|
||||
{
|
||||
ZoneScoped;
|
||||
lua_close(L);
|
||||
}
|
||||
void run()
|
||||
{
|
||||
ZoneScoped;
|
||||
int result = luaL_dostring(L, cellScript.c_str());
|
||||
if (result != LUA_OK) {
|
||||
std::cerr << "Lua script execution failed: "
|
||||
@@ -1475,6 +1516,7 @@ out:
|
||||
};
|
||||
bool editRoofs(const Ogre::String &lotLabel, nlohmann::json &lot)
|
||||
{
|
||||
ZoneScoped;
|
||||
bool changed = false;
|
||||
static int roofPosition[3] = { 0, 0 };
|
||||
static int roofSize[2] = { 1, 1 };
|
||||
@@ -1625,6 +1667,7 @@ bool editRoofs(const Ogre::String &lotLabel, nlohmann::json &lot)
|
||||
}
|
||||
bool editLot(const Ogre::String &lotLabel, nlohmann::json &lot)
|
||||
{
|
||||
ZoneScoped;
|
||||
bool changed = false;
|
||||
float angle = lot["angle"].get<float>();
|
||||
if (ImGui::SliderFloat(("Lot Angle##" + lotLabel).c_str(), &angle,
|
||||
@@ -1794,6 +1837,7 @@ bool editLot(const Ogre::String &lotLabel, nlohmann::json &lot)
|
||||
}
|
||||
void commandEraseLot(nlohmann::json &district, int lotIndex)
|
||||
{
|
||||
ZoneScoped;
|
||||
nlohmann::json lots = nlohmann::json::array();
|
||||
for (const auto &lot : district["lots"])
|
||||
lots.push_back(lot);
|
||||
@@ -1802,6 +1846,7 @@ void commandEraseLot(nlohmann::json &district, int lotIndex)
|
||||
}
|
||||
void cleanupLot(nlohmann::json &lot)
|
||||
{
|
||||
ZoneScoped;
|
||||
lot.erase("cells");
|
||||
lot.erase("furniture_cells");
|
||||
lot.erase("roofs");
|
||||
@@ -1809,6 +1854,7 @@ void cleanupLot(nlohmann::json &lot)
|
||||
void addLotTemplate(nlohmann::json &district, nlohmann::json &lotTemplates,
|
||||
int lotIndex)
|
||||
{
|
||||
ZoneScoped;
|
||||
if (district.find("lots") != district.end()) {
|
||||
nlohmann::json &lots = district["lots"];
|
||||
nlohmann::json lotTemplate = lots[lotIndex];
|
||||
@@ -1820,6 +1866,7 @@ void addLotFromTemplate(nlohmann::json &district,
|
||||
const nlohmann::json &lotTemplates,
|
||||
int lotTemplateIndex)
|
||||
{
|
||||
ZoneScoped;
|
||||
nlohmann::json lots = nlohmann::json::array();
|
||||
OgreAssert(lotTemplateIndex < lotTemplates.size() &&
|
||||
lotTemplates.size() > 0,
|
||||
@@ -1855,6 +1902,7 @@ void addLotFromTemplate(nlohmann::json &district,
|
||||
void addLot(nlohmann::json &district, float angle, int width, int depth,
|
||||
float elevation, const Ogre::String &script)
|
||||
{
|
||||
ZoneScoped;
|
||||
nlohmann::json lots = nlohmann::json::array();
|
||||
for (const auto &lot : district["lots"])
|
||||
lots.push_back(lot);
|
||||
@@ -1873,6 +1921,7 @@ void addLot(nlohmann::json &district, float angle, int width, int depth,
|
||||
bool editDistrict(const Ogre::String &districtLabel, nlohmann::json &district,
|
||||
nlohmann::json &lotTemplates)
|
||||
{
|
||||
ZoneScoped;
|
||||
bool changed = false;
|
||||
nlohmann::json lots = nlohmann::json::array();
|
||||
for (const auto &lot : district["lots"])
|
||||
@@ -1973,6 +2022,7 @@ bool editDistrict(const Ogre::String &districtLabel, nlohmann::json &district,
|
||||
}
|
||||
bool editColorRects(nlohmann::json &rects)
|
||||
{
|
||||
ZoneScoped;
|
||||
bool changed = false;
|
||||
ImGui::Text("Color Rects");
|
||||
for (auto it = rects.begin(); it != rects.end(); it++) {
|
||||
@@ -2072,6 +2122,7 @@ bool editColorRects(nlohmann::json &rects)
|
||||
}
|
||||
void runAllScriptsForTown(flecs::entity e)
|
||||
{
|
||||
ZoneScoped;
|
||||
Ogre::String prop = StaticGeometryModule::getItemProperties(e);
|
||||
nlohmann::json j = nlohmann::json::parse(prop);
|
||||
auto &districts = j["districts"];
|
||||
@@ -2093,6 +2144,7 @@ void runAllScriptsForTown(flecs::entity e)
|
||||
}
|
||||
bool editNPCs(nlohmann::json &npcs)
|
||||
{
|
||||
ZoneScoped;
|
||||
bool changed = false;
|
||||
ImGui::Text("NPC");
|
||||
int id = 0;
|
||||
@@ -2221,6 +2273,7 @@ bool editNPCs(nlohmann::json &npcs)
|
||||
}
|
||||
void createTownPopup(const std::pair<flecs::entity, Ogre::String> item)
|
||||
{
|
||||
ZoneScoped;
|
||||
Ogre::String prop = StaticGeometryModule::getItemProperties(item.first);
|
||||
Ogre::Vector3 townPosition;
|
||||
Ogre::Quaternion townRotation;
|
||||
@@ -2341,6 +2394,7 @@ struct ProcessCells {
|
||||
std::vector<struct BitSet> bits_int_corners2;
|
||||
ProcessCells()
|
||||
{
|
||||
ZoneScoped;
|
||||
bits_ext_corners = {
|
||||
{ 4 | 16, // external wall
|
||||
4.0f,
|
||||
@@ -2955,6 +3009,7 @@ struct ProcessCells {
|
||||
void clampUV(flecs::entity e, Procedural::TriangleBuffer &tb,
|
||||
const Ogre::String &rectKey)
|
||||
{
|
||||
ZoneScoped;
|
||||
Ogre::String props = e.get<TerrainItem>().properties;
|
||||
nlohmann::json jp = nlohmann::json::parse(props);
|
||||
nlohmann::json colorRects = nlohmann::json::object();
|
||||
@@ -2979,6 +3034,7 @@ void clampUV(flecs::entity e, Procedural::TriangleBuffer &tb,
|
||||
}
|
||||
Ogre::MaterialPtr createTownMaterial(flecs::entity e, bool force)
|
||||
{
|
||||
ZoneScoped;
|
||||
Ogre::MaterialPtr townMaterial;
|
||||
Ogre::String props = e.get<TerrainItem>().properties;
|
||||
nlohmann::json jp = nlohmann::json::parse(props);
|
||||
@@ -3101,6 +3157,7 @@ Ogre::MaterialPtr createTownMaterial(flecs::entity e, bool force)
|
||||
}
|
||||
void createTownWindows(flecs::entity e)
|
||||
{
|
||||
ZoneScoped;
|
||||
Ogre::MeshPtr frame1mesh =
|
||||
Ogre::MeshManager::getSingleton().getByName("window-frame1");
|
||||
if (!frame1mesh) {
|
||||
@@ -3196,6 +3253,7 @@ void createTownWindows(flecs::entity e)
|
||||
}
|
||||
void createTownDoors(flecs::entity e)
|
||||
{
|
||||
ZoneScoped;
|
||||
Ogre::MeshPtr extframe1mesh =
|
||||
Ogre::MeshManager::getSingleton().getByName(
|
||||
"external-door-frame1");
|
||||
@@ -3335,6 +3393,7 @@ struct TownTask {
|
||||
const Ogre::Vector3 &position,
|
||||
const Ogre::Quaternion &orientation)
|
||||
{
|
||||
ZoneScoped;
|
||||
Ogre::Entity *ent =
|
||||
ECS::get<EngineData>().mScnMgr->createEntity(mesh);
|
||||
ent->setMaterial(material);
|
||||
@@ -3345,6 +3404,7 @@ struct TownTask {
|
||||
const Ogre::Vector3 &position,
|
||||
const Ogre::Quaternion &orientation)
|
||||
{
|
||||
ZoneScoped;
|
||||
JPH::ShapeRefC shape =
|
||||
JoltPhysicsWrapper::getSingleton().createMeshShape(
|
||||
mesh);
|
||||
@@ -3411,6 +3471,7 @@ struct TownPlazza : TownTask {
|
||||
queueData,
|
||||
localPosition,
|
||||
localRotation]() {
|
||||
ZoneScoped;
|
||||
const nlohmann::json &jp = queueData->jp;
|
||||
float radius = 5.0f;
|
||||
float height = 0.2f;
|
||||
@@ -3491,10 +3552,12 @@ struct TownPlazza : TownTask {
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
ZoneScoped;
|
||||
createTownPlazza(e, jdistrict, index, sceneNode, geo);
|
||||
}
|
||||
void wait()
|
||||
{
|
||||
ZoneScoped;
|
||||
if (townPlazzaComplete.valid() &&
|
||||
townPlazzaComplete.wait_for(std::chrono::seconds(0)) !=
|
||||
std::future_status::ready)
|
||||
@@ -3611,6 +3674,7 @@ struct TownLots : TownTask {
|
||||
Ogre::Root::getSingleton().getWorkQueue()->addTask([radius,
|
||||
baseHeight,
|
||||
promise]() {
|
||||
ZoneScoped;
|
||||
std::cout << "lots count: " << lots.size() << std::endl;
|
||||
OgreAssert(lots.size() > 0, "bad lots count");
|
||||
for (auto &lot : lots) {
|
||||
@@ -3706,10 +3770,12 @@ struct TownLots : TownTask {
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
ZoneScoped;
|
||||
createTownLots(e, jdistrict, index, sceneNode, geo);
|
||||
}
|
||||
void wait()
|
||||
{
|
||||
ZoneScoped;
|
||||
if (townLotsComplete.valid() &&
|
||||
townLotsComplete.wait_for(std::chrono::seconds(0)) !=
|
||||
std::future_status::ready)
|
||||
@@ -3722,6 +3788,7 @@ struct TownCells : TownTask {
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
ZoneScoped;
|
||||
struct QueueData {
|
||||
Procedural::TriangleBuffer tb;
|
||||
Ogre::Vector3 position;
|
||||
@@ -3838,6 +3905,7 @@ struct TownCells : TownTask {
|
||||
baseHeight,
|
||||
promise]() {
|
||||
{
|
||||
ZoneScoped;
|
||||
int count = 0;
|
||||
for (auto &lot : lots) {
|
||||
for (auto &jcell : lot.jlot["cells"]) {
|
||||
@@ -4020,10 +4088,12 @@ struct TownCells : TownTask {
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
ZoneScoped;
|
||||
createCells(e, jdistrict, index, sceneNode, geo);
|
||||
}
|
||||
void wait()
|
||||
{
|
||||
ZoneScoped;
|
||||
if (townCellsComplete.valid() &&
|
||||
townCellsComplete.wait_for(std::chrono::seconds(0)) !=
|
||||
std::future_status::ready)
|
||||
@@ -4037,6 +4107,7 @@ struct TownRoofs : TownTask {
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
ZoneScoped;
|
||||
struct QueueData {
|
||||
Procedural::TriangleBuffer tb;
|
||||
Ogre::Vector3 position;
|
||||
@@ -4154,6 +4225,7 @@ struct TownRoofs : TownTask {
|
||||
}
|
||||
Ogre::Root::getSingleton().getWorkQueue()->addTask([radius,
|
||||
promise]() {
|
||||
ZoneScoped;
|
||||
for (auto &lot : lots) {
|
||||
for (auto &jroof : lot.jlot["roofs"]) {
|
||||
int roofType = jroof["type"].get<int>();
|
||||
@@ -4887,10 +4959,12 @@ struct TownRoofs : TownTask {
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
ZoneScoped;
|
||||
createTownRoofs(e, jdistrict, index, sceneNode, geo);
|
||||
}
|
||||
void wait()
|
||||
{
|
||||
ZoneScoped;
|
||||
if (townRoofsComplete.valid() &&
|
||||
townRoofsComplete.wait_for(std::chrono::seconds(0)) !=
|
||||
std::future_status::ready)
|
||||
@@ -4905,6 +4979,7 @@ struct TownDecorateWindows : TownTask {
|
||||
Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
ZoneScoped;
|
||||
// FIXME: make furniture placement a background task.
|
||||
Ogre::MaterialPtr townMaterial = createTownMaterial(e);
|
||||
const nlohmann::json &jp = jdistrict;
|
||||
@@ -5118,10 +5193,12 @@ struct TownDecorateWindows : TownTask {
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
ZoneScoped;
|
||||
createDecorateWindows(e, jdistrict, index, sceneNode, geo);
|
||||
}
|
||||
void wait()
|
||||
{
|
||||
ZoneScoped;
|
||||
if (townDecorateWindowsComplete.valid() &&
|
||||
townDecorateWindowsComplete.wait_for(std::chrono::seconds(
|
||||
0)) != std::future_status::ready)
|
||||
@@ -5135,6 +5212,7 @@ struct TownDecorateDoors : TownTask {
|
||||
Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
ZoneScoped;
|
||||
// FIXME: make furniture placement a background task.
|
||||
Ogre::MaterialPtr townMaterial = createTownMaterial(e);
|
||||
const nlohmann::json &jp = jdistrict;
|
||||
@@ -5432,10 +5510,12 @@ struct TownDecorateDoors : TownTask {
|
||||
int index, Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
ZoneScoped;
|
||||
createDecorateDoors(e, jdistrict, index, sceneNode, geo);
|
||||
}
|
||||
void wait()
|
||||
{
|
||||
ZoneScoped;
|
||||
if (townDecorateDoorsComplete.valid() &&
|
||||
townDecorateDoorsComplete.wait_for(std::chrono::seconds(
|
||||
0)) != std::future_status::ready)
|
||||
@@ -5449,6 +5529,7 @@ struct TownDecorateFurniture : TownTask {
|
||||
Ogre::SceneNode *sceneNode,
|
||||
Ogre::StaticGeometry *geo)
|
||||
{
|
||||
ZoneScoped;
|
||||
// FIXME: make furniture placement a background task.
|
||||
Ogre::MaterialPtr townMaterial = createTownMaterial(e);
|
||||
const nlohmann::json &jp = jdistrict;
|
||||
@@ -5930,6 +6011,7 @@ void createTown(flecs::entity e, Ogre::SceneNode *sceneNode,
|
||||
}
|
||||
}
|
||||
Ogre::Root::getSingleton().getWorkQueue()->addTask([geo]() {
|
||||
ZoneScoped;
|
||||
for (auto m : townTasks)
|
||||
m->wait();
|
||||
Ogre::Root::getSingleton().getWorkQueue()->addMainThreadTask(
|
||||
|
||||
Reference in New Issue
Block a user