using distance to ray argument for optimization

This commit is contained in:
devZoGok
2024-07-21 15:00:49 +03:00
parent 027dfc2071
commit fdaa2bf2bd
4 changed files with 27 additions and 8 deletions
+8 -1
View File
@@ -2,6 +2,7 @@
#include "gameObjectFrameController.h"
#include "resourceDeposit.h"
#include "defConfigs.h"
#include "player.h"
#include "game.h"
#include "unit.h"
@@ -118,7 +119,13 @@ namespace battleship{
frame.update();
Vector3 startPos = Root::getSingleton()->getCamera()->getPosition();
vector<RayCaster::CollisionResult> results = RayCaster::cast(startPos, (screenToSpace(getCursorPos()) - startPos).norm(), Map::getSingleton()->getNodeParent()->getChild(0));
vector<RayCaster::CollisionResult> results = RayCaster::cast(
startPos,
(screenToSpace(getCursorPos()) - startPos).norm(),
Map::getSingleton()->getNodeParent()->getChild(0),
0,
configData::DIST_FROM_RAY
);
if(results.empty()) return;