mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Optimize pushing collision data for entity on_step
Since this is fixed overhead for every entity, this is important to optimize. This optimizes one very common case. before: push_collision_move_result [us] _____________ 64512x 3.562 after: push_collision_move_result [us] _____________ 72636x 0.831
This commit is contained in:
parent
2e89529eef
commit
c24a04d246
4 changed files with 65 additions and 15 deletions
|
@ -97,3 +97,25 @@ function core.encode_png(width, height, data, compression)
|
|||
|
||||
return o_encode_png(width, height, data, compression or 6)
|
||||
end
|
||||
|
||||
-- Helper that pushes a collisionMoveResult structure
|
||||
if core.set_push_moveresult1 then
|
||||
-- must match CollisionAxis in collision.h
|
||||
local AXES = {"x", "y", "z"}
|
||||
-- <=> script/common/c_content.cpp push_collision_move_result()
|
||||
core.set_push_moveresult1(function(b0, b1, b2, axis, npx, npy, npz, v0x, v0y, v0z, v1x, v1y, v1z)
|
||||
return {
|
||||
touching_ground = b0,
|
||||
collides = b1,
|
||||
standing_on_object = b2,
|
||||
collisions = {{
|
||||
type = "node",
|
||||
axis = AXES[axis],
|
||||
node_pos = vector.new(npx, npy, npz),
|
||||
old_velocity = vector.new(v0x, v0y, v0z),
|
||||
new_velocity = vector.new(v1x, v1y, v1z),
|
||||
}},
|
||||
}
|
||||
end)
|
||||
core.set_push_moveresult1 = nil
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue