1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Fix situation around aabbox3d default constructor (#15586)

Co-authored-by: JosiahWI <41302989+JosiahWI@users.noreply.github.com>
This commit is contained in:
sfan5 2024-12-29 14:36:30 +01:00 committed by GitHub
parent cca65fde08
commit f2b1cc3e61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 67 additions and 53 deletions

View file

@ -101,7 +101,7 @@ std::vector<DistanceSortedActiveObject> ActiveObjectMgr::getActiveSelectableObje
if (!obj)
continue;
aabb3f selection_box;
aabb3f selection_box{{0.0f, 0.0f, 0.0f}};
if (!obj->getSelectionBox(&selection_box))
continue;

View file

@ -430,7 +430,7 @@ void ClientEnvironment::getSelectedActiveObjects(
for (const auto &allObject : allObjects) {
ClientActiveObject *obj = allObject.obj;
aabb3f selection_box;
aabb3f selection_box{{0.0f, 0.0f, 0.0f}};
if (!obj->getSelectionBox(&selection_box))
continue;

View file

@ -160,7 +160,7 @@ private:
// Was the mesh ever generated?
bool m_mesh_valid = false;
aabb3f m_box;
aabb3f m_box{{0.0f, 0.0f, 0.0f}};
v2f m_origin;
u16 m_cloud_radius_i;
u32 m_seed;

View file

@ -3200,7 +3200,7 @@ PointedThing Game::updatePointedThing(
hud->pointing_at_object = true;
runData.selected_object = client->getEnv().getActiveObject(result.object_id);
aabb3f selection_box;
aabb3f selection_box{{0.0f, 0.0f, 0.0f}};
if (show_entity_selectionbox && runData.selected_object->doShowSelectionBox() &&
runData.selected_object->getSelectionBox(&selection_box)) {
v3f pos = runData.selected_object->getPosition();

View file

@ -75,10 +75,8 @@ static aabb3f getNodeBoundingBox(const std::vector<aabb3f> &nodeboxes)
if (nodeboxes.empty())
return aabb3f(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
aabb3f b_max;
std::vector<aabb3f>::const_iterator it = nodeboxes.begin();
b_max = aabb3f(it->MinEdge, it->MaxEdge);
auto it = nodeboxes.begin();
aabb3f b_max(it->MinEdge, it->MaxEdge);
++it;
for (; it != nodeboxes.end(); ++it)

View file

@ -105,8 +105,7 @@ void scaleMesh(scene::IMesh *mesh, v3f scale)
if (mesh == NULL)
return;
aabb3f bbox;
bbox.reset(0, 0, 0);
aabb3f bbox{{0.0f, 0.0f, 0.0f}};
u32 mc = mesh->getMeshBufferCount();
for (u32 j = 0; j < mc; j++) {
@ -134,8 +133,7 @@ void translateMesh(scene::IMesh *mesh, v3f vec)
if (mesh == NULL)
return;
aabb3f bbox;
bbox.reset(0, 0, 0);
aabb3f bbox{{0.0f, 0.0f, 0.0f}};
u32 mc = mesh->getMeshBufferCount();
for (u32 j = 0; j < mc; j++) {
@ -296,8 +294,7 @@ void rotateMeshBy6dFacedir(scene::IMesh *mesh, u8 facedir)
void recalculateBoundingBox(scene::IMesh *src_mesh)
{
aabb3f bbox;
bbox.reset(0,0,0);
aabb3f bbox{{0.0f, 0.0f, 0.0f}};
for (u16 j = 0; j < src_mesh->getMeshBufferCount(); j++) {
scene::IMeshBuffer *buf = src_mesh->getMeshBuffer(j);
buf->recalculateBoundingBox();

View file

@ -619,15 +619,22 @@ const core::aabbox3df &ParticleBuffer::getBoundingBox() const
if (!m_bounding_box_dirty)
return m_mesh_buffer->BoundingBox;
core::aabbox3df box;
core::aabbox3df box{{0, 0, 0}};
bool first = true;
for (u16 i = 0; i < m_count; i++) {
// check if this index is used
static_assert(quad_indices[1] != 0);
if (m_mesh_buffer->getIndices()[6 * i + 1] == 0)
continue;
for (u16 j = 0; j < 4; j++)
box.addInternalPoint(m_mesh_buffer->getPosition(i * 4 + j));
for (u16 j = 0; j < 4; j++) {
const auto pos = m_mesh_buffer->getPosition(i * 4 + j);
if (first)
box.reset(pos);
else
box.addInternalPoint(pos);
first = false;
}
}
m_mesh_buffer->BoundingBox = box;

View file

@ -50,8 +50,6 @@ Sky::Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShade
m_seed = (u64)myrand() << 32 | myrand();
setAutomaticCulling(scene::EAC_OFF);
m_box.MaxEdge.set(0, 0, 0);
m_box.MinEdge.set(0, 0, 0);
m_sky_params = SkyboxDefaults::getSkyDefaults();
m_sun_params = SkyboxDefaults::getSunDefaults();

View file

@ -122,7 +122,7 @@ public:
}
private:
aabb3f m_box;
aabb3f m_box{{0.0f, 0.0f, 0.0f}};
video::SMaterial m_materials[SKY_MATERIAL_COUNT];
// How much sun & moon transition should affect horizon color
float m_horizon_blend()

View file

@ -195,8 +195,7 @@ WieldMeshSceneNode::WieldMeshSceneNode(scene::ISceneManager *mgr, s32 id):
else
g_extrusion_mesh_cache->grab();
// Disable bounding box culling for this scene node
// since we won't calculate the bounding box.
// This class doesn't render anything, so disable culling.
setAutomaticCulling(scene::EAC_OFF);
// Create the child scene node

View file

@ -134,7 +134,7 @@ private:
// Bounding box culling is disabled for this type of scene node,
// so this variable is just required so we can implement
// getBoundingBox() and is set to an empty box.
aabb3f m_bounding_box;
aabb3f m_bounding_box{{0, 0, 0}};
ShadowRenderer *m_shadow;
};

View file

@ -262,7 +262,7 @@ static void add_object_boxes(Environment *env,
{
auto process_object = [&cinfo] (ActiveObject *object) {
if (object && object->collideWithObjects()) {
aabb3f box;
aabb3f box{{0.0f, 0.0f, 0.0f}};
if (object->getCollisionBox(&box))
cinfo.emplace_back(object, 0, box);
}

View file

@ -121,7 +121,7 @@ void NodeBox::deSerialize(std::istream &is)
case NODEBOX_LEVELED: {
u16 fixed_count = readU16(is);
while(fixed_count--) {
aabb3f box;
aabb3f box{{0.0f, 0.0f, 0.0f}};
box.MinEdge = readV3F32(is);
box.MaxEdge = readV3F32(is);
fixed.push_back(box);

View file

@ -115,9 +115,9 @@ struct NodeBox
// NODEBOX_FIXED
std::vector<aabb3f> fixed;
// NODEBOX_WALLMOUNTED
aabb3f wall_top;
aabb3f wall_bottom;
aabb3f wall_side; // being at the -X side
aabb3f wall_top = dummybox;
aabb3f wall_bottom = dummybox;
aabb3f wall_side = dummybox; // being at the -X side
// NODEBOX_CONNECTED
// (kept externally to not bloat the structure)
std::shared_ptr<NodeBoxConnected> connected;
@ -139,6 +139,10 @@ struct NodeBox
void reset();
void serialize(std::ostream &os, u16 protocol_version) const;
void deSerialize(std::istream &is);
private:
/// @note the actual defaults are in reset(), see nodedef.cpp
static constexpr aabb3f dummybox = aabb3f({0, 0, 0});
};
struct MapNode;
@ -810,14 +814,14 @@ private:
* The union of all nodes' selection boxes.
* Might be larger if big nodes are removed from the manager.
*/
aabb3f m_selection_box_union;
aabb3f m_selection_box_union{{0.0f, 0.0f, 0.0f}};
/*!
* The smallest box in integer node coordinates that
* contains all nodes' selection boxes.
* Might be larger if big nodes are removed from the manager.
*/
core::aabbox3d<s16> m_selection_box_int_union;
core::aabbox3d<s16> m_selection_box_int_union{{0, 0, 0}};
/*!
* NodeResolver instances to notify once node registration has finished.

View file

@ -302,7 +302,7 @@ private:
v3s16 m_start; /**< source position */
v3s16 m_destination; /**< destination position */
core::aabbox3d<s16> m_limits; /**< position limits in real map coordinates */
core::aabbox3d<s16> m_limits{{0, 0, 0}}; /**< position limits in real map coordinates */
/** contains all map data already collected and analyzed.
Access it via the getIndexElement/getIdxElem methods. */

View file

@ -326,7 +326,8 @@ bool is_color_table(lua_State *L, int index)
aabb3f read_aabb3f(lua_State *L, int index, f32 scale)
{
aabb3f box;
// default value for accidental/historical reasons
aabb3f box{-1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f};
if(lua_istable(L, index)){
lua_rawgeti(L, index, 1);
box.MinEdge.X = lua_tonumber(L, -1) * scale;

View file

@ -85,7 +85,19 @@ bool read_color (lua_State *L, int index,
video::SColor *color);
bool is_color_table (lua_State *L, int index);
/**
* Read a floating-point axis-aligned box from Lua.
*
* @param L the Lua state
* @param index the index of the Lua variable to read the box from. The
* variable must contain a table of the form
* {minx, miny, minz, maxx, maxy, maxz}.
* @param scale factor to scale the bounding box by
*
* @return the box corresponding to lua table
*/
aabb3f read_aabb3f (lua_State *L, int index, f32 scale);
v3s16 read_v3s16 (lua_State *L, int index);
std::vector<aabb3f> read_aabb3f_vector (lua_State *L, int index, f32 scale);
size_t read_stringlist (lua_State *L, int index,

View file

@ -1847,7 +1847,7 @@ void ServerEnvironment::getSelectedActiveObjects(
auto process = [&] (ServerActiveObject *obj) -> bool {
if (obj->isGone())
return false;
aabb3f selection_box;
aabb3f selection_box{{0.0f, 0.0f, 0.0f}};
if (!obj->getSelectionBox(&selection_box))
return false;