added drawline for raycast

This commit is contained in:
Lendemor 2017-08-26 23:12:01 +02:00
parent 89de721187
commit 130dff16d4
3 changed files with 12 additions and 0 deletions

View File

@ -51,6 +51,7 @@ public:
SparrowRenderer* getRenderer() const {return m_renderer;}
btDiscreteDynamicsWorld* getPhysics() const {return m_world;}
SparrowShell* getShell() const {return m_sparrowshell;}
PhysicsDebugNode* getPhysicsDebug() const {return m_physicsDebugNode;}
GuiTools* getGuiTools() const {return m_guiTools;}
SceneTree* getScene() const;

View File

@ -6,6 +6,8 @@
#include <glm/ext.hpp>
#include "scene/physicsdebugnode.h"
#include "scenetree.h"
#include "lightnode.h"
#include <SFML/System.hpp>
@ -222,6 +224,11 @@ void PlayerCharacterNode::update()
getEngine().getPhysics()->rayTest(start_front, end_front, RayCallback_front);
getEngine().getPhysics()->rayTest(start_back, end_back, RayCallback_back);
PhysicsDebugNode* pdnode= getEngine().getPhysicsDebug();
if (pdnode != nullptr){
pdnode->drawLine(start_front,end_front,btVector3(1,0,1));
pdnode->drawLine(start_back,end_back,btVector3(1,0,1));
}
float controlRatio = 0.2f; // 1 = total control, 0 = no control, can be seen as a slipperiness factor
if(RayCallback_back.hasHit()){

View File

@ -4,6 +4,7 @@
#include "guitools.h"
#include "scene/scenetree.h"
#include "scene/playercharacternode.h"
#include "scene/physicsdebugnode.h"
#include <SparrowRenderer/parametricmesh.h>
#include <SparrowRenderer/pbrmaterial.h>
@ -76,6 +77,9 @@ void ScenePicker::pick()
btVector3 end = start;
end += btVector3(start.x() + dir_cam.x, start.y() + dir_cam.y, start.z() + dir_cam.z);
btCollisionWorld::ClosestRayResultCallback RayCallback(start, end);
PhysicsDebugNode* pdnode= getEngine().getPhysicsDebug();
if (pdnode != nullptr)
pdnode->drawLine(start,end,btVector3(1,0,1));
getEngine().getPhysics()->rayTest(start,end,RayCallback);
m_pickSucceeded = RayCallback.hasHit();