mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
proper bounds
This commit is contained in:
parent
408e2b64e2
commit
2c0ceb6731
@ -102,7 +102,29 @@ output(ostream &out) const {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PT(BoundingVolume) CollisionFloorMesh::
|
PT(BoundingVolume) CollisionFloorMesh::
|
||||||
compute_internal_bounds() const {
|
compute_internal_bounds() const {
|
||||||
return new BoundingBox(LPoint3f(0,0,0), LPoint3f(1,1,1));
|
if (_vertices.empty()) {
|
||||||
|
return new BoundingBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pvector<LPoint3f>::const_iterator pi = _vertices.begin();
|
||||||
|
LPoint3f p = (*pi);
|
||||||
|
|
||||||
|
LPoint3f x = p;
|
||||||
|
LPoint3f n = p;
|
||||||
|
|
||||||
|
for (++pi; pi != _vertices.end(); ++pi) {
|
||||||
|
p = *pi;
|
||||||
|
|
||||||
|
n.set(min(n[0], p[0]),
|
||||||
|
min(n[1], p[1]),
|
||||||
|
min(n[2], p[2]));
|
||||||
|
x.set(max(x[0], p[0]),
|
||||||
|
max(x[1], p[1]),
|
||||||
|
max(x[2], p[2]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BoundingBox(n, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user