Navigation adjusting
This commit is contained in:
1 parent
e618c91415
commit
b973d714cc
22 files changed
+6219
-64
No files matched your search
+21
-2
@@ -165,8 +165,27 @@ namespace ZL
|
||||
uniInteriorParams.gameObjectsJsonPath = "resources/config2/gameobjects_uni_interior.json";
|
||||
uniInteriorParams.npcsJsonPath = "resources/config2/npcs_uni_interior.json";
|
||||
uniInteriorParams.dialoguesJsonPath = "resources/dialogue/uni_interior_dialogues.json";
|
||||
//uniInteriorParams.navigationJsonPaths = {"resources/config2/navigation.json"};
|
||||
uniInteriorParams.navigationJsonPaths = { "resources/w/nav_uni_interior.txt" };
|
||||
|
||||
/*uniInteriorParams.navigationJsonPaths = {
|
||||
"resources/navigation/uni_interior1_night.json",
|
||||
"resources/config2/navigation_interior.json",
|
||||
"resources/config2/navigation_interior.json",
|
||||
"resources/config2/navigation_interior.json",
|
||||
"resources/config2/navigation_interior.json",
|
||||
"resources/config2/navigation_interior.json",
|
||||
"resources/config2/navigation_interior.json"
|
||||
};*/
|
||||
//uniInteriorParams.navigationJsonPaths = {"resources/navigation/uni_interior_basic0_objects_opendoors.json"};
|
||||
//uniInteriorParams.navigationJsonPaths = { "resources/w/nav_uni_interior.txt" };
|
||||
uniInteriorParams.navigationJsonPaths = {
|
||||
"resources/navigation/uni_interior0_all_locked.txt",
|
||||
"resources/navigation/uni_interior0_hall.txt",
|
||||
"resources/navigation/uni_interior0_lr_hall.txt",
|
||||
"resources/navigation/uni_interior_basic0_objects_opendoors.txt",
|
||||
"resources/navigation/uni_interior0_aiperi_lr_tr_hall.json",
|
||||
"resources/navigation/uni_interior1_night.txt"
|
||||
};
|
||||
|
||||
uniInteriorParams.teleportsJsonPath = "resources/config2/teleports.json";
|
||||
uniInteriorParams.triggerZonesJsonPath = "resources/config2/trigger_zones_uni_interior.json";
|
||||
uniInteriorParams.scriptPath = "resources/start_uni_interior.lua";
|
||||
|
||||
+21
-21
@@ -501,59 +501,59 @@ namespace ZL
|
||||
|
||||
InteractiveObject* Location::raycastInteractiveObjects(const Eigen::Vector3f& rayOrigin, const Eigen::Vector3f& rayDir) {
|
||||
if (interactiveObjects.empty()) {
|
||||
std::cout << "[RAYCAST] No interactive objects to check" << std::endl;
|
||||
//std::cout << "[RAYCAST] No interactive objects to check" << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::cout << "[RAYCAST] Starting raycast with " << interactiveObjects.size() << " objects" << std::endl;
|
||||
std::cout << "[RAYCAST] Ray origin: (" << rayOrigin.x() << ", " << rayOrigin.y() << ", " << rayOrigin.z() << ")" << std::endl;
|
||||
std::cout << "[RAYCAST] Ray dir: (" << rayDir.x() << ", " << rayDir.y() << ", " << rayDir.z() << ")" << std::endl;
|
||||
//std::cout << "[RAYCAST] Starting raycast with " << interactiveObjects.size() << " objects" << std::endl;
|
||||
//std::cout << "[RAYCAST] Ray origin: (" << rayOrigin.x() << ", " << rayOrigin.y() << ", " << rayOrigin.z() << ")" << std::endl;
|
||||
//std::cout << "[RAYCAST] Ray dir: (" << rayDir.x() << ", " << rayDir.y() << ", " << rayDir.z() << ")" << std::endl;
|
||||
|
||||
float closestDistance = FLT_MAX;
|
||||
InteractiveObject* closestObject = nullptr;
|
||||
|
||||
for (auto& intObj : interactiveObjects) {
|
||||
std::cout << "[RAYCAST] Checking object: " << intObj.loadedObject.name << " (active: " << intObj.isActive << ")" << std::endl;
|
||||
//std::cout << "[RAYCAST] Checking object: " << intObj.loadedObject.name << " (active: " << intObj.isActive << ")" << std::endl;
|
||||
|
||||
if (!intObj.isActive || intObj.isAnimating) {
|
||||
std::cout << "[RAYCAST] -> Object inactive or animating, skipping" << std::endl;
|
||||
//std::cout << "[RAYCAST] -> Object inactive or animating, skipping" << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
std::cout << "[RAYCAST] Position: (" << intObj.position.x() << ", " << intObj.position.y() << ", "
|
||||
<< intObj.position.z() << "), Radius: " << intObj.interactionRadius << std::endl;
|
||||
//std::cout << "[RAYCAST] Position: (" << intObj.position.x() << ", " << intObj.position.y() << ", "
|
||||
// << intObj.position.z() << "), Radius: " << intObj.interactionRadius << std::endl;
|
||||
|
||||
Eigen::Vector3f toObject = intObj.position - rayOrigin;
|
||||
std::cout << "[RAYCAST] Vector to object: (" << toObject.x() << ", " << toObject.y() << ", " << toObject.z() << ")" << std::endl;
|
||||
//std::cout << "[RAYCAST] Vector to object: (" << toObject.x() << ", " << toObject.y() << ", " << toObject.z() << ")" << std::endl;
|
||||
|
||||
float distanceAlongRay = toObject.dot(rayDir);
|
||||
std::cout << "[RAYCAST] Distance along ray: " << distanceAlongRay << std::endl;
|
||||
//std::cout << "[RAYCAST] Distance along ray: " << distanceAlongRay << std::endl;
|
||||
|
||||
if (distanceAlongRay < 0.1f) {
|
||||
std::cout << "[RAYCAST] -> Object behind camera, skipping" << std::endl;
|
||||
//std::cout << "[RAYCAST] -> Object behind camera, skipping" << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
Eigen::Vector3f closestPointOnRay = rayOrigin + rayDir * distanceAlongRay;
|
||||
float distToObject = (closestPointOnRay - intObj.position).norm();
|
||||
|
||||
std::cout << "[RAYCAST] Distance to object: " << distToObject
|
||||
<< " (interaction radius: " << intObj.interactionRadius << ")" << std::endl;
|
||||
//std::cout << "[RAYCAST] Distance to object: " << distToObject
|
||||
// << " (interaction radius: " << intObj.interactionRadius << ")" << std::endl;
|
||||
|
||||
if (distToObject <= intObj.interactionRadius && distanceAlongRay < closestDistance) {
|
||||
std::cout << "[RAYCAST] *** HIT DETECTED! ***" << std::endl;
|
||||
//std::cout << "[RAYCAST] *** HIT DETECTED! ***" << std::endl;
|
||||
closestDistance = distanceAlongRay;
|
||||
closestObject = &intObj;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (closestObject) {
|
||||
std::cout << "[RAYCAST] *** RAYCAST SUCCESS: Found object " << closestObject->loadedObject.name << " ***" << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "[RAYCAST] No objects hit" << std::endl;
|
||||
}
|
||||
|
||||
*/
|
||||
return closestObject;
|
||||
}
|
||||
|
||||
@@ -567,11 +567,11 @@ namespace ZL
|
||||
Character* closestNpc = nullptr;
|
||||
float closestDist = maxDistance;
|
||||
|
||||
std::cout << "[RAYCAST_NPC] Starting raycast with " << npcs.size() << " npcs" << std::endl;
|
||||
//std::cout << "[RAYCAST_NPC] Starting raycast with " << npcs.size() << " npcs" << std::endl;
|
||||
|
||||
for (auto& npc : npcs) {
|
||||
if (npc->hp <= 0.f) {
|
||||
std::cout << "[RAYCAST_NPC] " << npc->npcId << " is dead, skipping" << std::endl;
|
||||
//std::cout << "[RAYCAST_NPC] " << npc->npcId << " is dead, skipping" << std::endl;
|
||||
continue;
|
||||
}
|
||||
if (!npc->enabled) continue;
|
||||
@@ -607,7 +607,7 @@ namespace ZL
|
||||
|
||||
if (entryT > exitT) continue;
|
||||
|
||||
std::cout << "[RAYCAST_NPC] " << npc->npcId << " hit at t=" << entryT << std::endl;
|
||||
//std::cout << "[RAYCAST_NPC] " << npc->npcId << " hit at t=" << entryT << std::endl;
|
||||
|
||||
if (entryT < closestDist) {
|
||||
closestDist = entryT;
|
||||
@@ -616,10 +616,10 @@ namespace ZL
|
||||
}
|
||||
|
||||
if (closestNpc) {
|
||||
std::cout << "[RAYCAST_NPC] HIT: " << closestNpc->npcId << std::endl;
|
||||
//std::cout << "[RAYCAST_NPC] HIT: " << closestNpc->npcId << std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "[RAYCAST_NPC] No NPC hit" << std::endl;
|
||||
//std::cout << "[RAYCAST_NPC] No NPC hit" << std::endl;
|
||||
}
|
||||
|
||||
return closestNpc;
|
||||
|
||||
Reference in new issue
Block a user