Proper walls geometry with frames

This commit is contained in:
2026-04-06 19:31:10 +03:00
parent d8122e3275
commit 19e4d80741
5 changed files with 882 additions and 196 deletions

View File

@@ -72,6 +72,7 @@ public:
// Getters
flecs::entity getSelectedEntity() const;
Ogre::SceneManager *getSceneManager() const { return m_sceneMgr; }
flecs::world *getWorld() { return &m_world; }
private:
// Ogre objects

View File

@@ -59,6 +59,16 @@ namespace CellFlags {
IntDoorXNeg | IntDoorXPos | IntDoorZPos | IntDoorZNeg;
constexpr uint64_t AllWindows = WindowXNeg | WindowXPos | WindowZPos | WindowZNeg |
IntWindowXNeg | IntWindowXPos | IntWindowZPos | IntWindowZNeg;
// Combined masks for corners (walls + doors + windows in each direction)
constexpr uint64_t AllXNeg = WallXNeg | DoorXNeg | WindowXNeg;
constexpr uint64_t AllXPos = WallXPos | DoorXPos | WindowXPos;
constexpr uint64_t AllZPos = WallZPos | DoorZPos | WindowZPos;
constexpr uint64_t AllZNeg = WallZNeg | DoorZNeg | WindowZNeg;
constexpr uint64_t AllIntXNeg = IntWallXNeg | IntDoorXNeg | IntWindowXNeg;
constexpr uint64_t AllIntXPos = IntWallXPos | IntDoorXPos | IntWindowXPos;
constexpr uint64_t AllIntZPos = IntWallZPos | IntDoorZPos | IntWindowZPos;
constexpr uint64_t AllIntZNeg = IntWallZNeg | IntDoorZNeg | IntWindowZNeg;
}
/**
@@ -127,6 +137,8 @@ struct CellGridComponent {
std::string doorRectName;
std::string windowRectName;
std::string roofRectName;
std::string windowFrameRectName;
std::string doorFrameRectName;
// Dirty flag - triggers rebuild
bool dirty = true;

View File

@@ -1,14 +1,22 @@
#include <iostream>
#include "EditorApp.hpp"
#include "systems/SceneSerializer.hpp"
int main(int argc, char *argv[])
{
(void)argc;
(void)argv;
try {
EditorApp app;
app.initApp();
// Auto-load scene if provided as argument
if (argc > 1) {
std::cout << "Auto-loading scene: " << argv[1] << std::endl;
SceneSerializer serializer(*app.getWorld(), app.getSceneManager());
if (!serializer.loadFromFile(argv[1])) {
std::cerr << "Failed to load scene: " << serializer.getLastError() << std::endl;
}
}
app.getRoot()->startRendering();
app.closeApp();
} catch (const std::exception &e) {

File diff suppressed because it is too large Load Diff

View File

@@ -57,6 +57,16 @@ private:
// Build lot base geometry
void buildLotBase(flecs::entity entity, struct LotComponent& lot);
// Build window and door frames (3D frame meshes)
void buildFrames(flecs::entity entity, const struct CellGridComponent& grid, const std::string& materialName);
void createWindowFrameMeshes(const struct CellGridComponent& grid, const std::string& materialName,
const std::string& meshPrefix, flecs::entity materialEntity);
void createDoorFrameMeshes(const struct CellGridComponent& grid, const std::string& materialName,
const std::string& meshPrefix, flecs::entity materialEntity);
void placeWindowFrames(flecs::entity entity, const struct CellGridComponent& grid, Ogre::StaticGeometry* geo, std::vector<Ogre::Entity*>& frameEntities);
void placeDoorFrames(flecs::entity entity, const struct CellGridComponent& grid, Ogre::StaticGeometry* geo, std::vector<Ogre::Entity*>& frameEntities);
void destroyFrames(flecs::entity entity);
// Convert triangle buffer to mesh
Ogre::MeshPtr convertToMesh(const std::string& name, Procedural::TriangleBuffer& tb, const std::string& materialName);
@@ -81,6 +91,15 @@ private:
std::vector<std::string> windowMeshes;
std::string roofMesh;
std::vector<Ogre::Entity*> entities;
// Frame meshes (unique per CellGrid for cellSize/cellHeight adaptation)
std::string externalWindowFrameMesh;
std::string internalWindowFrameMesh;
std::string externalDoorFrameMesh;
std::string internalDoorFrameMesh;
// StaticGeometry for frames (per CellGrid)
Ogre::StaticGeometry* framesStaticGeo = nullptr;
};
std::unordered_map<uint64_t, MeshData> m_entityMeshes;