mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-15 15:02:34 +02:00
Merge pull request #106 from JayFoxRox/debug-jump-and-flip
Debug features: "Jump to Debug Camera" and "Flip Vehicle"
This commit is contained in:
commit
d490f8c7c6
@ -8,18 +8,21 @@
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtx/string_cast.hpp>
|
||||
|
||||
void jumpCharacter(RWGame* game, CharacterObject* player, const glm::vec3& target)
|
||||
static void jumpCharacter(RWGame* game, CharacterObject* player, const glm::vec3& target, bool ground = true)
|
||||
{
|
||||
glm::vec3 ground = game->getWorld()->getGroundAtPosition(target);
|
||||
glm::vec3 newPosition = target;
|
||||
if (ground) {
|
||||
newPosition = game->getWorld()->getGroundAtPosition(newPosition) + glm::vec3(0.f, 0.f, 1.f);
|
||||
}
|
||||
if( player )
|
||||
{
|
||||
if( player->getCurrentVehicle() )
|
||||
{
|
||||
player->getCurrentVehicle()->setPosition(ground + glm::vec3(0.f, 0.f, 1.f));
|
||||
player->getCurrentVehicle()->setPosition(newPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
player->setPosition(ground + glm::vec3(0.f, 0.f, 1.f));
|
||||
player->setPosition(newPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -85,6 +88,9 @@ DebugState::DebugState(RWGame* game, const glm::vec3& vp, const glm::quat& vd)
|
||||
m->addEntry(Menu::lambda("Quickload", [=] {
|
||||
game->loadGame("quicksave");
|
||||
}, entryHeight));
|
||||
m->addEntry(Menu::lambda("Jump to Debug Camera", [=] {
|
||||
jumpCharacter(game, game->getPlayer()->getCharacter(), _debugCam.position + _debugCam.rotation * glm::vec3(3.f, 0.f, 0.f), false);
|
||||
}, entryHeight));
|
||||
m->addEntry(Menu::lambda("Jump to Garage", [=] {
|
||||
jumpCharacter(game, game->getPlayer()->getCharacter(), glm::vec3(270.f, -605.f, 40.f));
|
||||
}, entryHeight));
|
||||
@ -124,6 +130,15 @@ DebugState::DebugState(RWGame* game, const glm::vec3& vp, const glm::quat& vd)
|
||||
game->getRenderer()->setCullOverride(true, _debugCam);
|
||||
}, entryHeight));
|
||||
|
||||
// Optional block if the player is in a vehicle
|
||||
auto player = game->getPlayer()->getCharacter();
|
||||
auto cv = player->getCurrentVehicle();
|
||||
if(cv) {
|
||||
m->addEntry(Menu::lambda("Flip vehicle", [=] {
|
||||
cv->setRotation(cv->getRotation() * glm::quat(glm::vec3(0.f, glm::pi<float>(), 0.f)));
|
||||
}, entryHeight));
|
||||
}
|
||||
|
||||
this->enterMenu(m);
|
||||
|
||||
_debugCam.position = vp;
|
||||
|
Loading…
Reference in New Issue
Block a user