little cleanup

This commit is contained in:
Vladislav Khorev 2026-05-09 20:28:25 +03:00
parent 13ef92160d
commit 72e05cdc28
15 changed files with 323 additions and 197 deletions

View File

@ -126,7 +126,7 @@
"interactive": true,
"item": {
"id": "journal",
"name": "Телефон",
"name": "Журнал",
"description": "Это мой журнал куда я вношу свои заметки.",
"icon": "resources/fire2.png",
"radius": 0.3

View File

@ -0,0 +1,43 @@
{
"npcs": [
{
"id": "npc_teacher01",
"name": "Аида Дженибекова",
"animationIdlePath": "resources/w/new_anims/teacher_stand_idle001.txt",
"animationWalkPath": "resources/w/new_anims/woman_walk4_001.txt",
"meshTextures": {
"Teacher_lowpoly": "resources/w/new_anims/UniV_Grid_2K.001_Base_color.png"
},
"positionX": -0.28594,
"positionY": 0,
"positionZ": 13.9641,
"walkSpeed": 1.3,
"rotationSpeed": 8.0,
"modelScale": 1.0,
"modelCorrectionRotX": -90.0,
"modelCorrectionRotY": 180.0,
"modelCorrectionRotZ": 0.0,
"interactionRadius": 1.0
},
{
"id": "npc_02_woman",
"name": "Бегимай",
"animationIdlePath": "resources/w/girl/girl_walk002.txt",
"animationWalkPath": "resources/w/girl/girl_walk002.txt",
"meshTextures": {
"polySurface1": "resources/w/girl/Chat_02_diff_1.png"
},
"positionX": 0.764049,
"positionY": 0.0,
"positionZ": -8.53475,
"facingAngle" : 3.141592,
"walkSpeed": 1.66,
"rotationSpeed": 8.0,
"modelScale": 0.016,
"modelCorrectionRotX": 0.0,
"modelCorrectionRotY": 180.0,
"modelCorrectionRotZ": 0.0,
"interactionRadius": 2.0
}
]
}

View File

@ -7,7 +7,7 @@
"positionZ": -9.37259,
"radius": 1.5,
"active": true,
"destinationLocation": "location2",
"destinationLocation": "uni_exterior",
"destinationPositionX": 8.2,
"destinationPositionY": 0.0,
"destinationPositionZ": -9.9,

View File

@ -7,7 +7,7 @@
"positionZ": -9.9,
"radius": 1.5,
"active": true,
"destinationLocation": "location1",
"destinationLocation": "uni_interior",
"destinationPositionX": 2.64621,
"destinationPositionY": 0.0,
"destinationPositionZ": -9.37259,

View File

@ -7,7 +7,7 @@
"positionZ": -0.152264,
"radius": 1.5,
"active": true,
"destinationLocation": "location2",
"destinationLocation": "uni_exterior",
"destinationPositionX": -21.7327,
"destinationPositionY": 0.0,
"destinationPositionZ": -34.1036,

View File

@ -1,4 +0,0 @@
{
"trigger_zones": [
]
}

View File

@ -0,0 +1,22 @@
{
"trigger_zones": [
{
"id": "lection_hall_zone001",
"positionX": -0.141875,
"positionY": 0.0,
"positionZ": 9.75898,
"radius": 2.0,
"hysteresis": 0.1,
"enabled": true
},
{
"id": "knife_dialog_zone001",
"positionX":-0.0765023,
"positionY": 0.0,
"positionZ": -7.90549,
"radius": 1.0,
"hysteresis": 0.1,
"enabled": true
}
]
}

View File

@ -0,0 +1,187 @@
{
"dialogues": [
{
"id": "knife_dialog001",
"start": "line_1",
"nodes": [
{
"id": "line_1",
"type": "Line",
"speaker": "Бермет",
"portrait": "resources/w/avatar_girlfriend.png",
"text": "Ты куда собрался, Бекзат?",
"next": "line_2"
},
{
"id": "line_2",
"type": "Line",
"speaker": "Бермет",
"portrait": "resources/w/avatar_girlfriend.png",
"text": "Пока ты не заберешь нож из учительской, никуда я тебя не выпущу.",
"next": "end_1"
},
{
"id": "end_1",
"type": "End"
}
]
}
],
"cutscenes": [
{
"id": "test_cutscene_01",
"background": "resources/first_cutscene.png",
"durationMs": 6800,
"cameraTrack": [
{
"durationMs": 2400,
"from": { "focusX": 0.50, "focusY": 0.55, "zoom": 1.00, "rotationDeg": 0.0 },
"to": { "focusX": 0.63, "focusY": 0.58, "zoom": 1.16, "rotationDeg": -1.0 },
"easing": "EaseInOutSine"
},
{
"durationMs": 2200,
"from": { "focusX": 0.63, "focusY": 0.58, "zoom": 1.16, "rotationDeg": -1.0 },
"to": { "focusX": 0.74, "focusY": 0.52, "zoom": 1.30, "rotationDeg": -2.4 },
"easing": "EaseInOutCubic"
},
{
"durationMs": 2200,
"from": { "focusX": 0.74, "focusY": 0.52, "zoom": 1.30, "rotationDeg": -2.4 },
"to": { "focusX": 0.58, "focusY": 0.46, "zoom": 1.10, "rotationDeg": -0.6 },
"easing": "EaseOutSine"
}
],
"lines": [
{
"speaker": "Narrator",
"portrait": "resources/hero.png",
"text": "The air in the room turned cold.",
"durationMs": 2200
},
{
"speaker": "Ghost",
"portrait": "resources/w/avatar_ghost.png",
"text": "Some memories never fade.",
"durationMs": 2600,
"background": "resources/loading.png"
}
]
},
{
"id": "test_cutscene_silent_01",
"background": "resources/first_cutscene.png",
"durationMs": 5200,
"cameraTrack": [
{
"durationMs": 2600,
"from": { "focusX": 0.40, "focusY": 0.54, "zoom": 1.00, "rotationDeg": 0.0 },
"to": { "focusX": 0.58, "focusY": 0.54, "zoom": 1.22, "rotationDeg": 0.8 },
"easing": "EaseInOutSine"
},
{
"durationMs": 2600,
"from": { "focusX": 0.58, "focusY": 0.54, "zoom": 1.22, "rotationDeg": 0.8 },
"to": { "focusX": 0.72, "focusY": 0.48, "zoom": 1.34, "rotationDeg": -0.5 },
"easing": "EaseOutCubic"
}
],
"lines": []
},
{
"id": "test_cutscene_pan_01",
"background": "resources/first_cutscene.png",
"durationMs": 12000,
"cameraTrack": [
{
"durationMs": 1200,
"from": { "anchor": "Center", "zoom": 1.00, "rotationDeg": 0.0 },
"to": { "anchor": "Center", "zoom": 1.00, "rotationDeg": 0.0 },
"easing": "Linear"
},
{
"durationMs": 2500,
"from": { "anchor": "Center", "zoom": 1.00, "rotationDeg": 0.0 },
"to": { "anchor": "TopLeft", "zoom": 1.55, "rotationDeg": 0.0 },
"easing": "EaseInOutSine"
},
{
"durationMs": 2600,
"from": { "anchor": "TopLeft", "zoom": 1.55, "rotationDeg": 0.0 },
"to": { "anchor": "TopRight", "zoom": 1.55, "rotationDeg": 0.0 },
"easing": "EaseInOutSine"
},
{
"durationMs": 1800,
"from": { "anchor": "TopRight", "zoom": 1.55, "rotationDeg": 0.0 },
"to": { "anchor": "BottomRight", "zoom": 1.72, "rotationDeg": 0.0 },
"easing": "EaseInCubic"
},
{
"durationMs": 3900,
"from": { "anchor": "BottomRight", "zoom": 1.72, "rotationDeg": 0.0 },
"to": { "anchor": "BottomLeft", "zoom": 1.55, "rotationDeg": 0.0 },
"easing": "EaseInOutSine"
}
],
"lines": [
{
"speaker": "Narrator",
"portrait": "resources/hero.png",
"text": "The memory begins in silence.",
"durationMs": 2200
},
{
"speaker": "Narrator",
"portrait": "resources/hero.png",
"text": "Something is drawing your eyes across the whole scene.",
"durationMs": 2800
},
{
"speaker": "Ghost",
"portrait": "resources/ghost_avatar.png",
"text": "Do not look away.",
"durationMs": 2400
}
]
},
{
"id": "test_cutscene_pan_02",
"background": "resources/first_cutscene.png",
"durationMs": 12000,
"cameraTrack": [
{
"durationMs": 1200,
"from": { "anchor": "Center", "zoom": 1.00, "rotationDeg": 0.0 },
"to": { "anchor": "Center", "zoom": 1.00, "rotationDeg": 0.0 },
"easing": "Linear"
},
{
"durationMs": 2500,
"from": { "anchor": "Center", "zoom": 1.00, "rotationDeg": 0.0 },
"to": { "anchor": "TopLeft", "zoom": 1.55, "rotationDeg": 0.0 },
"easing": "EaseInOutSine"
},
{
"durationMs": 2600,
"from": { "anchor": "TopLeft", "zoom": 1.55, "rotationDeg": 0.0 },
"to": { "anchor": "TopRight", "zoom": 1.55, "rotationDeg": 0.0 },
"easing": "EaseInOutSine"
},
{
"durationMs": 1800,
"from": { "anchor": "TopRight", "zoom": 1.55, "rotationDeg": 0.0 },
"to": { "anchor": "BottomRight", "zoom": 1.72, "rotationDeg": 0.0 },
"easing": "EaseInCubic"
},
{
"durationMs": 3900,
"from": { "anchor": "BottomRight", "zoom": 1.72, "rotationDeg": 0.0 },
"to": { "anchor": "BottomLeft", "zoom": 1.55, "rotationDeg": 0.0 },
"easing": "EaseInOutSine"
}
],
"lines": []
}
]
}

View File

@ -1,52 +0,0 @@
-- ============================================
-- NPC PATROL WAYPOINTS
-- ============================================
local function step3()
game_api.npc_walk_to(0, 0.0, 0.0, -30.0, step1)
end
local function step2()
game_api.npc_walk_to(0, -2.0, 0.0, -2.0, step3)
end
function step1()
game_api.npc_walk_to(0, 2.0, 0.0, -2.0, step2)
end
--step1()
local function step3x()
game_api.npc_walk_to(2, 2.0, 0.0, -27.0, step1x)
end
local function step2x()
game_api.npc_walk_to(2, -1.0, 0.0, -12.0, step3x)
end
function step1x()
game_api.npc_walk_to(2, 2.0, 0.0, -16.0, step2x)
end
--step1x()
-- ============================================
-- ITEM PICKUP HANDLER
-- ============================================
function on_health_pickup()
game_api.pickup_item("health_potion")
print("[Lua] Health potion picked up!")
end
-- ============================================
-- NPC INTERACTION HANDLER
-- ============================================
function on_npc_interact(npc_index)
print("[Lua] NPC interaction! Index: " .. tostring(npc_index))
game_api.start_dialogue("ghost_choice_dialogue")
end
print("Lua script loaded successfully!")

View File

@ -0,0 +1,33 @@
function lection_hall_zone001_enter_callback()
--game_api.start_dialogue("")
--Start cutscene
end
game_api.set_trigger_zone_callbacks("lection_hall_zone001",
lection_hall_zone001_enter_callback,
nil
)
function knife_dialog_zone001_enter_callback()
print("knife_dialog_zone001_enter_callback--!")
if (not phone_picked_up) or (not journal_picked_up) then
game_api.start_dialogue("knife_dialog001")
game_api.switch_navigation(0)
end
end
function knife_dialog_zone001_exit_callback()
print("knife_dialog_zone001_exit_callback--!")
game_api.switch_navigation(0)
end
game_api.set_trigger_zone_callbacks("knife_dialog_zone001",
knife_dialog_zone001_enter_callback,
knife_dialog_zone001_exit_callback
)
print("Lua script loaded successfully!")

View File

@ -158,38 +158,32 @@ namespace ZL
std::cout << "Load resurces step 4" << std::endl;
LocationSetup params1;
params1.roomMeshPath = "resources/w/room003.txt";
params1.roomTexturePath = "resources/w/room005.png";
params1.gameObjectsJsonPath = "resources/config2/gameobjects.json";
params1.npcsJsonPath = "resources/config2/npcs.json";
params1.dialoguesJsonPath = "resources/dialogue/sample_dialogues.json";
params1.navigationJsonPaths = {"resources/config2/navigation.json"};
params1.teleportsJsonPath = "resources/config2/teleports.json";
params1.triggerZonesJsonPath = "resources/config2/trigger_zones.json";
params1.scriptPath = "resources/start.lua";
params1.playerPosition = Eigen::Vector3f(0.942694, 0, -9.63104);
LocationSetup uniInteriorParams;
uniInteriorParams.gameObjectsJsonPath = "resources/config2/gameobjects.json";
uniInteriorParams.npcsJsonPath = "resources/config2/npcs_uni_interior.json";
uniInteriorParams.dialoguesJsonPath = "resources/dialogue/uni_interior_dialogues.json";
uniInteriorParams.navigationJsonPaths = {"resources/config2/navigation.json"};
uniInteriorParams.teleportsJsonPath = "resources/config2/teleports.json";
uniInteriorParams.triggerZonesJsonPath = "resources/config2/trigger_zones_uni_interior.json";
uniInteriorParams.scriptPath = "resources/start_uni_interior.lua";
uniInteriorParams.playerPosition = Eigen::Vector3f(0.942694, 0, -9.63104);
locations["location1"] = std::make_shared<Location>(renderer, inventory);
locations["location1"]->setup(params1);
locations["uni_interior"] = std::make_shared<Location>(renderer, inventory);
locations["uni_interior"]->setup(uniInteriorParams);
LocationSetup params2 = params1;
params2.roomMeshPath = "resources/w/exterior/Segmented_Plane002.txt";
params2.roomTexturePath = "resources/w/exterior/Segmented_Plane002.png";
params2.gameObjectsJsonPath = "resources/config2/gameobjects2.json";
params2.navigationJsonPaths = {"resources/config2/navigation2.json"};
params2.teleportsJsonPath = "resources/config2/teleports2.json";
params2.triggerZonesJsonPath = "resources/config2/trigger_zones2.json";
params2.scriptPath = "resources/start2.lua";
params2.playerPosition = Eigen::Vector3f(5, 0, -18.4);
params2.npcsJsonPath = "resources/config2/npcs2.json";
LocationSetup uniExteriorParams = uniInteriorParams;
uniExteriorParams.gameObjectsJsonPath = "resources/config2/gameobjects2.json";
uniExteriorParams.navigationJsonPaths = {"resources/config2/navigation2.json"};
uniExteriorParams.teleportsJsonPath = "resources/config2/teleports2.json";
uniExteriorParams.triggerZonesJsonPath = "resources/config2/trigger_zones2.json";
uniExteriorParams.scriptPath = "resources/start2.lua";
uniExteriorParams.playerPosition = Eigen::Vector3f(5, 0, -18.4);
uniExteriorParams.npcsJsonPath = "resources/config2/npcs2.json";
locations["uni_exterior"] = std::make_shared<Location>(renderer, inventory);
locations["uni_exterior"]->setup(uniExteriorParams);
locations["location2"] = std::make_shared<Location>(renderer, inventory);
locations["location2"]->setup(params2);
LocationSetup params_dorm;
params_dorm.roomMeshPath = "";
params_dorm.roomTexturePath = "";
params_dorm.gameObjectsJsonPath = "resources/config2/gameobjects_dorm.json";
params_dorm.npcsJsonPath = "resources/config2/npcs_dorm.json";
params_dorm.dialoguesJsonPath = "resources/dialogue/dorm_dialogues.json";
@ -203,9 +197,8 @@ namespace ZL
locations["location_dorm"]->setup(params_dorm);
// Teleport callbacks: destination name and position come from the teleport zone data.
auto makeTeleportCallback = [this](const std::string& sourceName) {
return [this, sourceName](const std::string& destName, const Eigen::Vector3f& destPos, float destRotY) {
std::cout << "[TELEPORT] " << sourceName << " -> " << destName << std::endl;
auto teleportCallback = [this](const std::string& destName, const Eigen::Vector3f& destPos, float destRotY) {
std::cout << "[TELEPORT] " << " -> " << destName << std::endl;
auto it = locations.find(destName);
if (it == locations.end()) {
std::cerr << "[TELEPORT] Unknown destination location: " << destName << std::endl;
@ -219,12 +212,12 @@ namespace ZL
currentLocation->player->targetFacingAngle = destRotY;
}
currentLocation->cameraAzimuth = destRotY;
};
};
locations["location1"]->onTeleport = makeTeleportCallback("location1");
locations["location2"]->onTeleport = makeTeleportCallback("location2");
locations["location_dorm"]->onTeleport = makeTeleportCallback("location_dorm");
locations["uni_exterior"]->onTeleport = teleportCallback;
locations["uni_interior"]->onTeleport = teleportCallback;
locations["location_dorm"]->onTeleport = teleportCallback;
currentLocation = locations["location_dorm"];
@ -548,8 +541,10 @@ namespace ZL
break;
case SDLK_p:
currentLocation = (currentLocation == locations["location1"]) ? locations["location2"] : locations["location1"];
std::cout << "Switched to location " << ((currentLocation == locations["location1"]) ? "1" : "2") << std::endl;
currentLocation = locations["uni_interior"];
currentLocation->player->position = Eigen::Vector3f(-0.0189243, 0, -13.4314);
currentLocation->player->setTarget(currentLocation->player->position);
//std::cout << "Switched to location " << ((currentLocation == locations["location1"]) ? "1" : "2") << std::endl;
break;
case SDLK_l:

View File

@ -52,11 +52,6 @@ namespace ZL
void Location::setup(const LocationSetup& params)
{
/*
roomTexture = renderer.textureManager.LoadFromPng(params.roomTexturePath, CONST_ZIP_FILE);
roomMesh.data = LoadFromTextFile02(params.roomMeshPath, CONST_ZIP_FILE);
roomMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(-M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
roomMesh.RefreshVBO();*/
// Load static game objects
gameObjects = GameObjectLoader::loadAndCreateGameObjects(params.gameObjectsJsonPath, renderer, CONST_ZIP_FILE);
@ -64,22 +59,12 @@ namespace ZL
// Load interactive objects
interactiveObjects = GameObjectLoader::loadAndCreateInteractiveObjects(params.gameObjectsJsonPath, renderer, CONST_ZIP_FILE);
//auto playerTexture = std::make_shared<Texture>(CreateTextureDataFromPng("resources/w/gg/IMG_20260413_182354_992.png", CONST_ZIP_FILE));
auto playerTexture = renderer.textureManager.LoadFromPng("resources/w/gg/UniV_Grid_2K_Base_color.png", CONST_ZIP_FILE);
auto sparkTexture = renderer.textureManager.LoadFromPng("resources/w/spark.png", CONST_ZIP_FILE);
player = std::make_unique<Character>();
/*
player->loadBinaryAnimation(AnimationState::STAND, "resources/w/gg/gg_stand_idle001.anim", CONST_ZIP_FILE);
player->loadBinaryAnimation(AnimationState::WALK, "resources/w/gg/gg_walking001.anim", CONST_ZIP_FILE);
player->loadBinaryAnimation(AnimationState::STAND_TO_ACTION, "resources/w/gg/gg_stand_to_action002.anim", CONST_ZIP_FILE);
player->loadBinaryAnimation(AnimationState::ACTION_ATTACK, "resources/w/gg/gg_action_attack001.anim", CONST_ZIP_FILE);
player->loadBinaryAnimation(AnimationState::ACTION_IDLE, "resources/w/gg/gg_action_idle001.anim", CONST_ZIP_FILE);
player->loadBinaryAnimation(AnimationState::ACTION_TO_STAND, "resources/w/gg/gg_action_to_stand001.anim", CONST_ZIP_FILE);
*/
player->loadBinaryAnimation(AnimationState::STAND, "resources/w/gg/new/gg_stand_idle001.anim", CONST_ZIP_FILE);
player->loadBinaryAnimation(AnimationState::WALK, "resources/w/gg/new/gg_walk001.anim", CONST_ZIP_FILE);
@ -95,11 +80,8 @@ namespace ZL
player->weaponTexture = renderer.textureManager.LoadFromPng("resources/w/white.png", CONST_ZIP_FILE);
//player->weaponMesh.AssignFrom(LoadFromTextFile02("resources/w/gg/knife001.txt", CONST_ZIP_FILE));
player->weaponMesh.data = LoadFromTextFile02("resources/w/gg/knife002.txt", CONST_ZIP_FILE);
player->weaponMesh.data.Scale(0.1f);
//player->weaponMesh.data.RotateByMatrix(Eigen::Quaternionf(Eigen::AngleAxisf(-M_PI * 0.5, Eigen::Vector3f::UnitY())).toRotationMatrix());
player->weaponMesh.RefreshVBO();
player->weaponAttachBoneName = "RightHand";
player->weaponInitialRotation = Eigen::AngleAxisf(-M_PI * 0.5, Eigen::Vector3f::UnitZ()).toRotationMatrix();
@ -156,17 +138,6 @@ namespace ZL
std::cerr << "Failed to init NPC name TextRenderer" << std::endl;
npcNameText.reset();
}
//dialogueSystem.loadDatabase("resources/dialogue/sample_dialogues.json");
/*dialogueSystem.addTriggerZone({
"ghost_room_trigger",
"test_line_dialogue",
Eigen::Vector3f(0.0f, 0.0f, -8.5f),
2.0f,
true,
false
});*/
// navigationMapPaths is already populated by setupNavigation
scriptEngine.init(this, &inventory, params.scriptPath);
@ -303,7 +274,7 @@ namespace ZL
navigationMaps.resize(paths.size());
for (size_t i = 0; i < paths.size(); ++i) {
navigationMaps[i].build({}, paths[i], CONST_ZIP_FILE);
navigationMaps[i].build(paths[i], CONST_ZIP_FILE);
}
activeNavigationIndex = 0;

View File

@ -31,8 +31,6 @@ namespace ZL
struct LocationSetup
{
std::string roomMeshPath;
std::string roomTexturePath;
std::string gameObjectsJsonPath;
std::string npcsJsonPath;
std::string dialoguesJsonPath;
@ -48,10 +46,6 @@ namespace ZL
public:
Location(Renderer& iRenderer, Inventory& iInventory);
//std::shared_ptr<Texture> roomTexture;
//VertexRenderStruct roomMesh;
std::unordered_map<std::string, LoadedGameObject> gameObjects;
std::vector<InteractiveObject> interactiveObjects;

View File

@ -87,14 +87,12 @@ namespace {
}
}
void PathFinder::build(const std::vector<ObstacleMesh>& obstacleMeshes,
const std::string& configPath,
void PathFinder::build(const std::string& configPath,
const std::string& zipPath)
{
ready = false;
loadedConfigPath = configPath;
loadedZipPath = zipPath;
obstacles = obstacleMeshes;
loadConfig(configPath, zipPath);
resetGridBounds();
@ -563,16 +561,6 @@ void PathFinder::resetGridBounds()
}
}
for (const ObstacleMesh& obstacle : obstacles) {
if (!obstacle.mesh) {
continue;
}
for (const Eigen::Vector3f& point : obstacle.mesh->PositionData) {
const Eigen::Vector3f worldPoint = point + obstacle.offset;
includePoint(worldPoint.x(), worldPoint.z());
}
}
for (const ObstaclePolygon& obstacle : obstaclePolygons) {
for (const Eigen::Vector2f& point : obstacle.polygon) {
includePoint(point.x(), point.y());
@ -593,7 +581,6 @@ void PathFinder::rebuildWalkableGrid()
{
walkable.assign(static_cast<size_t>(gridWidth * gridDepth), 0);
markAvailableAreasWalkable();
markObstacleMeshesBlocked();
markObstaclePolygonsBlocked();
}
@ -708,49 +695,6 @@ void PathFinder::markObstaclePolygonsBlocked()
}
}
void PathFinder::markObstacleMeshesBlocked()
{
if (!obstaclePolygons.empty()) {
// Prefer JSON-defined obstacle polygons over mesh-derived blockers.
// Mesh blockers tend to over-block (e.g. tree crowns) and are harder to author/tune.
return;
}
const float padding = agentRadius + objectPadding;
for (const ObstacleMesh& obstacle : obstacles) {
if (!obstacle.mesh || obstacle.mesh->PositionData.empty()) {
continue;
}
Eigen::Vector3f minPoint = obstacle.mesh->PositionData[0] + obstacle.offset;
Eigen::Vector3f maxPoint = minPoint;
for (const Eigen::Vector3f& localPoint : obstacle.mesh->PositionData) {
const Eigen::Vector3f point = localPoint + obstacle.offset;
minPoint = minPoint.cwiseMin(point);
maxPoint = maxPoint.cwiseMax(point);
}
Cell from;
Cell to;
worldToCell({ minPoint.x() - padding, floorY, minPoint.z() - padding }, from);
worldToCell({ maxPoint.x() + padding, floorY, maxPoint.z() + padding }, to);
from.x = (std::max)(from.x, 0);
from.z = (std::max)(from.z, 0);
to.x = (std::min)(to.x, gridWidth - 1);
to.z = (std::min)(to.z, gridDepth - 1);
for (int z = from.z; z <= to.z; ++z) {
for (int x = from.x; x <= to.x; ++x) {
const Cell cell{ x, z };
if (isInsideGrid(cell)) {
walkable[static_cast<size_t>(indexOf(cell))] = 0;
}
}
}
}
}
bool PathFinder::worldToCell(const Eigen::Vector3f& point, Cell& out) const
{
if (gridWidth <= 0 || gridDepth <= 0) {

View File

@ -9,10 +9,6 @@ namespace ZL {
class PathFinder {
public:
struct ObstacleMesh {
const VertexDataStruct* mesh = nullptr;
Eigen::Vector3f offset = Eigen::Vector3f::Zero();
};
struct ObstaclePolygon {
std::string name;
@ -35,8 +31,7 @@ public:
std::vector<Eigen::Vector2f> polygon;
};
void build(const std::vector<ObstacleMesh>& obstacleMeshes,
const std::string& configPath,
void build(const std::string& configPath,
const std::string& zipPath = "");
std::vector<Eigen::Vector3f> findPath(const Eigen::Vector3f& start,
@ -72,7 +67,6 @@ private:
std::string loadedConfigPath;
std::string loadedZipPath;
std::vector<ObstacleMesh> obstacles;
std::vector<ObstaclePolygon> obstaclePolygons;
std::vector<unsigned char> walkable;
std::vector<NavigationArea> areas;
@ -81,7 +75,6 @@ private:
void resetGridBounds();
void rebuildWalkableGrid();
void markAvailableAreasWalkable();
void markObstacleMeshesBlocked();
void markObstaclePolygonsBlocked();
bool worldToCell(const Eigen::Vector3f& point, Cell& out) const;