Working on path visualization
This commit is contained in:
1 parent
96e748715b
commit
0240721d46
12 files changed
+335
-3
No files matched your search
+25
-3
@@ -104,6 +104,7 @@ namespace FRG
|
||||
|
||||
void Location::setup(const LocationSetup& params, Quest::QuestJournal* journal, AudioPlayerAsync* audioPlayer)
|
||||
{
|
||||
pathVisualization.initialize();
|
||||
|
||||
// Load static game objects
|
||||
{
|
||||
@@ -708,6 +709,11 @@ namespace FRG
|
||||
renderer.shaderManager.PopShader();
|
||||
}
|
||||
|
||||
void Location::setPathVisualizationEnabled(bool enabled)
|
||||
{
|
||||
pathVisualization.setEnabled(enabled);
|
||||
}
|
||||
|
||||
void Location::drawGame()
|
||||
{
|
||||
|
||||
@@ -766,6 +772,7 @@ namespace FRG
|
||||
drawNpcCar();
|
||||
|
||||
for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height);
|
||||
pathVisualization.draw(renderer);
|
||||
|
||||
if (editorMode == EditorMode::Navigation) {
|
||||
editor.drawNavigation();
|
||||
@@ -986,6 +993,7 @@ namespace FRG
|
||||
|
||||
for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height);
|
||||
#endif
|
||||
pathVisualization.draw(renderer);
|
||||
|
||||
if (editorMode == EditorMode::Navigation) {
|
||||
editor.drawNavigation();
|
||||
@@ -1068,6 +1076,7 @@ namespace FRG
|
||||
//drawNpcCar();
|
||||
|
||||
for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height);
|
||||
pathVisualization.draw(renderer);
|
||||
|
||||
if (editorMode == EditorMode::Navigation) {
|
||||
editor.drawNavigation();
|
||||
@@ -1375,6 +1384,7 @@ namespace FRG
|
||||
drawNpcCar();
|
||||
|
||||
for (auto& tz : teleportZones) tz.draw(renderer, Environment::zoom, Environment::width, Environment::height);
|
||||
pathVisualization.draw(renderer);
|
||||
|
||||
if (editorMode == EditorMode::Navigation) {
|
||||
editor.drawNavigation();
|
||||
@@ -1669,6 +1679,8 @@ namespace FRG
|
||||
|
||||
void Location::update(int64_t delta)
|
||||
{
|
||||
pathVisualization.update(delta);
|
||||
|
||||
for (auto& intObj : interactiveObjects) {
|
||||
intObj.update(delta);
|
||||
}
|
||||
@@ -1986,6 +1998,10 @@ namespace FRG
|
||||
return;
|
||||
}
|
||||
|
||||
// Any new gameplay click invalidates the previous click feedback. Ground
|
||||
// clicks and interactive-object clicks that require walking start a replacement.
|
||||
pathVisualization.cancel();
|
||||
|
||||
//logger() << "[CLICK] Camera position: (" << camPos.x() << ", " << camPos.y() << ", " << camPos.z() << ")" << std::endl;
|
||||
//logger() << "[CLICK] Ray direction: (" << rayDir.x() << ", " << rayDir.y() << ", " << rayDir.z() << ")" << std::endl;
|
||||
|
||||
@@ -2001,9 +2017,13 @@ namespace FRG
|
||||
state.targetInteractiveObjectIndex = findInteractiveObjectIndex(clickedObject);
|
||||
state.targetInteractNpcIndex = -1;
|
||||
state.targetTeleportZoneIndex = -1;
|
||||
player->setTarget(clickedObject->state.hasInteractionPosition
|
||||
const Eigen::Vector3f interactionTarget = clickedObject->state.hasInteractionPosition
|
||||
? clickedObject->state.interactionPosition
|
||||
: clickedObject->state.position);
|
||||
: clickedObject->state.position;
|
||||
player->setTarget(interactionTarget);
|
||||
if (!player->state.pathWaypoints.empty()) {
|
||||
pathVisualization.start(*player, interactionTarget);
|
||||
}
|
||||
player->state.attackTargetIndex = CharacterState::kNoTarget;
|
||||
//logger() << "[CLICK] Player moving to object..." << std::endl;
|
||||
}
|
||||
@@ -2087,7 +2107,9 @@ namespace FRG
|
||||
player->setTarget(clickedTeleport->position);
|
||||
player->state.attackTargetIndex = CharacterState::kNoTarget;
|
||||
} else {
|
||||
player->setTarget(Eigen::Vector3f(hit.x(), 0.f, hit.z()));
|
||||
const Eigen::Vector3f clickedDestination(hit.x(), 0.f, hit.z());
|
||||
player->setTarget(clickedDestination);
|
||||
pathVisualization.start(*player, clickedDestination);
|
||||
player->state.attackTargetIndex = CharacterState::kNoTarget;
|
||||
state.targetInteractNpcIndex = -1;
|
||||
state.targetTeleportZoneIndex = -1;
|
||||
|
||||
Reference in new issue
Block a user