summaryrefslogtreecommitdiff
path: root/src/collision.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2018-04-04 00:43:08 +0200
committerGitHub <noreply@github.com>2018-04-04 00:43:08 +0200
commita90d27e1e23fa1c369c05a4d9c6083aa86ef7f52 (patch)
tree39f8d58d7ff29ae57a06e4239ae0b49b6dbed050 /src/collision.cpp
parent05fe3b06c80fc7fa438ed5faf5805c79a92789e9 (diff)
downloadminetest-a90d27e1e23fa1c369c05a4d9c6083aa86ef7f52.tar.gz
minetest-a90d27e1e23fa1c369c05a4d9c6083aa86ef7f52.tar.bz2
minetest-a90d27e1e23fa1c369c05a4d9c6083aa86ef7f52.zip
Optimize a little bit isBlockInSight, adjustDist & collisions (#7193)
* Use constexpr + unroll some calculations to cache definitively some calculations * Unroll some calls in collision code & use a constref instead of a copy in one occurence
Diffstat (limited to 'src/collision.cpp')
-rw-r--r--src/collision.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/collision.cpp b/src/collision.cpp
index e966ad19d..99874dbfd 100644
--- a/src/collision.cpp
+++ b/src/collision.cpp
@@ -322,9 +322,12 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
}
std::vector<aabb3f> nodeboxes;
n.getCollisionBoxes(gamedef->ndef(), &nodeboxes, neighbors);
+
+ // Calculate float position only once
+ v3f posf = intToFloat(p, BS);
for (auto box : nodeboxes) {
- box.MinEdge += intToFloat(p, BS);
- box.MaxEdge += intToFloat(p, BS);
+ box.MinEdge += posf;
+ box.MaxEdge += posf;
cinfo.emplace_back(false, false, n_bouncy_value, p, box);
}
} else {
@@ -437,7 +440,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
Go through every nodebox, find nearest collision
*/
for (u32 boxindex = 0; boxindex < cinfo.size(); boxindex++) {
- NearbyCollisionInfo box_info = cinfo[boxindex];
+ const NearbyCollisionInfo &box_info = cinfo[boxindex];
// Ignore if already stepped up this nodebox.
if (box_info.is_step_up)
continue;