Skip to content

Commit

Permalink
Revert "Optimize raycast performance (luanti-org#15233)"
Browse files Browse the repository at this point in the history
This reverts commit f7a695c.
  • Loading branch information
appgurueu committed Dec 14, 2024
1 parent 52a6673 commit f99a1a7
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 25 deletions.
2 changes: 0 additions & 2 deletions doc/lua_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9948,8 +9948,6 @@ Used by `core.register_node`.

selection_box = {
-- see [Node boxes] for possibilities
-- Selection boxes that oversize node size can cause
-- significant performance drop of Raycasts.
},
-- Custom selection box definition. Multiple boxes can be defined.
-- If "nodebox" drawtype is used and selection_box is nil, then node_box
Expand Down
6 changes: 0 additions & 6 deletions src/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ void Environment::continueRaycast(RaycastState *state, PointedThing *result_p)
break; // About to go out of bounds
}

const v3s16 pos_on_ray = state->m_iterator.m_current_node_pos;

// For each untested node
for (s16 z = new_nodes.MinEdge.Z; z <= new_nodes.MaxEdge.Z; z++)
for (s16 y = new_nodes.MinEdge.Y; y <= new_nodes.MaxEdge.Y; y++)
Expand All @@ -177,10 +175,6 @@ void Environment::continueRaycast(RaycastState *state, PointedThing *result_p)
if (!is_valid_position)
continue;

// Optimization: Skip non-oversized selection boxes for other positions.
if ((pos_on_ray != np) && !nodedef->get(n).has_big_selection_box)
continue;

PointabilityType pointable = isPointableNode(n, nodedef,
state->m_liquids_pointable,
state->m_pointabilities);
Expand Down
12 changes: 0 additions & 12 deletions src/nodedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1257,15 +1257,6 @@ inline void NodeDefManager::fixSelectionBoxIntUnion()
m_selection_box_union.MaxEdge.Z / BS - 0.5f);
}

inline void NodeDefManager::calcBigSelectionBox(content_t id, const ContentFeatures &def)
{
aabb3f box_union;
getNodeBoxUnion(def.selection_box, def, &box_union);
m_content_features[id].has_big_selection_box =
(box_union.MinEdge.X < -BS/2) || (box_union.MaxEdge.X > BS/2) ||
(box_union.MinEdge.Y < -BS/2) || (box_union.MaxEdge.Y > BS/2) ||
(box_union.MinEdge.Z < -BS/2) || (box_union.MaxEdge.Z > BS/2);
}

void NodeDefManager::eraseIdFromGroups(content_t id)
{
Expand Down Expand Up @@ -1321,7 +1312,6 @@ content_t NodeDefManager::set(const std::string &name, const ContentFeatures &de
getNodeBoxUnion(def.selection_box, def, &m_selection_box_union);
fixSelectionBoxIntUnion();

calcBigSelectionBox(id, def);
// Add this content to the list of all groups it belongs to
for (const auto &group : def.groups) {
const std::string &group_name = group.first;
Expand Down Expand Up @@ -1535,8 +1525,6 @@ void NodeDefManager::deSerialize(std::istream &is, u16 protocol_version)

getNodeBoxUnion(f.selection_box, f, &m_selection_box_union);
fixSelectionBoxIntUnion();

calcBigSelectionBox(i, f);
}

// Since liquid_alternative_flowing_id and liquid_alternative_source_id
Expand Down
5 changes: 0 additions & 5 deletions src/nodedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,6 @@ struct ContentFeatures
NodeBox node_box;
NodeBox selection_box;
NodeBox collision_box;
//! Whether any selection box extent is > BS/2.
bool has_big_selection_box;

// --- SOUND PROPERTIES ---

Expand Down Expand Up @@ -776,9 +774,6 @@ class NodeDefManager {
*/
void fixSelectionBoxIntUnion();

//! Calculates ContentFeatures::&has_big_selection_box
void calcBigSelectionBox(content_t id, const ContentFeatures &def);

//! Features indexed by ID.
std::vector<ContentFeatures> m_content_features;

Expand Down

0 comments on commit f99a1a7

Please sign in to comment.