aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorcutealien <cutealien@dfc29bdd-3216-0410-991c-e03cc46cb475>2022-09-29 14:12:12 +0000
committersfan5 <sfan5@live.de>2023-03-24 17:09:11 +0100
commit2bff14790434a36ab2a360b83eaebbd70e1e74ef (patch)
tree23280fc43571d26d2edb5aed97ffc23be805c2e7 /source
parent3cf75cdce41a9d1e40dc2398cca295bf28d54d2e (diff)
downloadirrlicht-2bff14790434a36ab2a360b83eaebbd70e1e74ef.tar.xz
Fix: Make CBillboardSceneNode bounding-box large enough to fit the billboard inside.
It still won't work yet for scaled boundingboxes (or parents being scaled). But at least it's now large enough for typical unscaled boundingboxes. Before it was always too small - even for the simplest quadratic billboard case seen without rotation. Now it's always a bit too large, but that's way less of a problem (collisions still work and culling simply happens a bit less often, but not too often which is way worse) git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6431 dfc29bdd-3216-0410-991c-e03cc46cb475
Diffstat (limited to 'source')
-rw-r--r--source/Irrlicht/CBillboardSceneNode.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/source/Irrlicht/CBillboardSceneNode.cpp b/source/Irrlicht/CBillboardSceneNode.cpp
index da90c3a..c1776d4 100644
--- a/source/Irrlicht/CBillboardSceneNode.cpp
+++ b/source/Irrlicht/CBillboardSceneNode.cpp
@@ -141,7 +141,7 @@ void CBillboardSceneNode::updateMesh(const irr::scene::ICameraSceneNode* camera)
//! returns the axis aligned bounding box of this node
const core::aabbox3d<f32>& CBillboardSceneNode::getBoundingBox() const
{
- // Really wrong when scaled.
+ // Really wrong when scaled (as the node does not scale it's vertices - maybe it should?)
return BBoxSafe;
}
@@ -162,9 +162,9 @@ void CBillboardSceneNode::setSize(const core::dimension2d<f32>& size)
if (core::equals(Size.Height, 0.0f))
Size.Height = 1.0f;
- const f32 avg = (Size.Width + Size.Height)/6;
- BBoxSafe.MinEdge.set(-avg,-avg,-avg);
- BBoxSafe.MaxEdge.set(avg,avg,avg);
+ const f32 extent = 0.5f*sqrt(Size.Width*Size.Width + Size.Height*Size.Height);
+ BBoxSafe.MinEdge.set(-extent,-extent,-extent);
+ BBoxSafe.MaxEdge.set(extent,extent,extent);
}
@@ -182,9 +182,9 @@ void CBillboardSceneNode::setSize(f32 height, f32 bottomEdgeWidth, f32 topEdgeWi
TopEdgeWidth = 1.0f;
}
- const f32 avg = (core::max_(Size.Width,TopEdgeWidth) + Size.Height)/6;
- BBoxSafe.MinEdge.set(-avg,-avg,-avg);
- BBoxSafe.MaxEdge.set(avg,avg,avg);
+ const f32 extent = 0.5f*sqrt(Size.Width*Size.Width + Size.Height*Size.Height);
+ BBoxSafe.MinEdge.set(-extent,-extent,-extent);
+ BBoxSafe.MaxEdge.set(extent,extent,extent);
}