ogre-cvsmail

 ```Update of /cvsroot/ogre/ogrenew/OgreMain/src In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16571/OgreMain/src Modified Files: OgreConvexBody.cpp OgreFrustum.cpp OgreMath.cpp OgrePlane.cpp OgreShadowCameraSetupFocused.cpp OgreShadowCaster.cpp Log Message: [ 1479228 ] AxisAlignedBox optimisations, modified a bit Also simplified / optimised some code in the new shadow projection classes Index: OgreConvexBody.cpp =================================================================== RCS file: /cvsroot/ogre/ogrenew/OgreMain/src/OgreConvexBody.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OgreConvexBody.cpp 14 Dec 2006 15:26:40 -0000 1.2 --- OgreConvexBody.cpp 2 Jan 2007 21:38:28 -0000 1.3 *************** *** 212,216 **** // 6-----7 ! const Vector3 *pts = aab.getAllCorners(); Polygon *poly; --- 212,219 ---- // 6-----7 ! const Vector3& min = aab.getMinimum(); ! const Vector3& max = aab.getMaximum(); ! ! Vector3 currentVertex = min; Polygon *poly; *************** *** 219,268 **** reset(); - // near - poly = allocatePolygon(); - poly->insertVertex( pts[4] ); - poly->insertVertex( pts[5] ); - poly->insertVertex( pts[6] ); - poly->insertVertex( pts[7] ); - insertPolygon( poly ); - // far poly = allocatePolygon(); ! poly->insertVertex( pts[1] ); ! poly->insertVertex( pts[2] ); ! poly->insertVertex( pts[3] ); ! poly->insertVertex( pts[0] ); insertPolygon( poly ); ! // left poly = allocatePolygon(); ! poly->insertVertex( pts[1] ); ! poly->insertVertex( pts[0] ); ! poly->insertVertex( pts[6] ); ! poly->insertVertex( pts[5] ); insertPolygon( poly ); ! // right poly = allocatePolygon(); ! poly->insertVertex( pts[2] ); ! poly->insertVertex( pts[4] ); ! poly->insertVertex( pts[7] ); ! poly->insertVertex( pts[3] ); insertPolygon( poly ); // bottom poly = allocatePolygon(); ! poly->insertVertex( pts[0] ); ! poly->insertVertex( pts[3] ); ! poly->insertVertex( pts[7] ); ! poly->insertVertex( pts[6] ); insertPolygon( poly ); // top poly = allocatePolygon(); ! poly->insertVertex( pts[2] ); ! poly->insertVertex( pts[1] ); ! poly->insertVertex( pts[5] ); ! poly->insertVertex( pts[4] ); insertPolygon( poly ); --- 222,290 ---- reset(); // far poly = allocatePolygon(); ! poly->insertVertex( currentVertex ); // 0 ! currentVertex.y = max.y; ! poly->insertVertex( currentVertex ); // 1 ! currentVertex.x = max.x; ! poly->insertVertex( currentVertex ); // 2 ! currentVertex.y = min.y; ! poly->insertVertex( currentVertex ); // 3 insertPolygon( poly ); ! // right poly = allocatePolygon(); ! poly->insertVertex( currentVertex ); // 3 ! currentVertex.y = max.y; ! poly->insertVertex( currentVertex ); // 2 ! currentVertex.z = max.z; ! poly->insertVertex( currentVertex ); // 4 ! currentVertex.y = min.y; ! poly->insertVertex( currentVertex ); // 7 insertPolygon( poly ); ! // near poly = allocatePolygon(); ! poly->insertVertex( currentVertex ); // 7 ! currentVertex.y = max.y; ! poly->insertVertex( currentVertex ); // 4 ! currentVertex.x = min.x; ! poly->insertVertex( currentVertex ); // 5 ! currentVertex.y = min.y; ! poly->insertVertex( currentVertex ); // 6 ! insertPolygon( poly ); ! ! // left ! poly = allocatePolygon(); ! poly->insertVertex( currentVertex ); // 6 ! currentVertex.y = max.y; ! poly->insertVertex( currentVertex ); // 5 ! currentVertex.z = min.z; ! poly->insertVertex( currentVertex ); // 1 ! currentVertex.y = min.y; ! poly->insertVertex( currentVertex ); // 0 insertPolygon( poly ); // bottom poly = allocatePolygon(); ! poly->insertVertex( currentVertex ); // 0 ! currentVertex.x = max.x; ! poly->insertVertex( currentVertex ); // 3 ! currentVertex.z = max.z; ! poly->insertVertex( currentVertex ); // 7 ! currentVertex.x = min.x; ! poly->insertVertex( currentVertex ); // 6 insertPolygon( poly ); // top poly = allocatePolygon(); ! currentVertex = max; ! poly->insertVertex( currentVertex ); // 4 ! currentVertex.z = min.z; ! poly->insertVertex( currentVertex ); // 2 ! currentVertex.x = min.x; ! poly->insertVertex( currentVertex ); // 1 ! currentVertex.z = max.z; ! poly->insertVertex( currentVertex ); // 5 insertPolygon( poly ); *************** *** 281,359 **** // 6-----7 ! const Vector3 *pts = aab.getAllCorners(); ! // clip object for each plane of the AAB ! Plane pl[6]; // front ! pl[0].redefine( pts[4], pts[5], pts[6] ); ! // back ! pl[1].redefine( pts[1], pts[2], pts[3] ); // left ! pl[2].redefine( pts[1], pts[0], pts[6] ); // right ! pl[3].redefine( pts[2], pts[4], pts[7] ); // bottom ! pl[4].redefine( pts[0], pts[3], pts[7] ); // top ! pl[5].redefine( pts[2], pts[1], pts[5] ); ! - // clip the body with each plane - for ( size_t i=0; i<6; ++i ) - { - clip(pl[i]); - } } //----------------------------------------------------------------------- void ConvexBody::clip(const Frustum& fr) { - - // ordering of the points: - // near (0-3), far (4-7); each (top-right, top-left, bottom-left, bottom-right) - // 5-----4 - // /| /| - // / | / | - // 1-----0 | - // | 6--|--7 - // | / | / - // |/ |/ - // 2-----3 - - const Vector3 *pts = fr.getWorldSpaceCorners(); - - - // clip object for each plane of the AAB - Plane pl[6]; - - // front - pl[0].redefine( pts[0], pts[1], pts[2] ); - - // back - pl[1].redefine( pts[5], pts[4], pts[7] ); - - // left - pl[2].redefine( pts[1], pts[5], pts[6] ); - - // right - pl[3].redefine( pts[4], pts[0], pts[3] ); - - // bottom - pl[4].redefine( pts[6], pts[7], pts[3] ); - - // top - pl[5].redefine( pts[4], pts[5], pts[1] ); - - // clip the body with each plane ! for ( size_t i = 0; i < 6; ++i ) { ! clip(pl[i]); } } --- 303,347 ---- // 6-----7 ! const Vector3& min = aab.getMinimum(); ! const Vector3& max = aab.getMaximum(); // clip object for each plane of the AAB ! Plane p; ! // front ! p.redefine(Vector3::UNIT_Z, max); ! clip(p); ! // back ! p.redefine(Vector3::NEGATIVE_UNIT_Z, min); ! clip(p); // left ! p.redefine(Vector3::NEGATIVE_UNIT_X, min); ! clip(p); // right ! p.redefine(Vector3::UNIT_X, max); ! clip(p); // bottom ! p.redefine(Vector3::NEGATIVE_UNIT_Y, min); ! clip(p); // top ! p.redefine(Vector3::UNIT_Y, max); ! clip(p); } //----------------------------------------------------------------------- void ConvexBody::clip(const Frustum& fr) { // clip the body with each plane ! for ( unsigned short i = 0; i < 6; ++i ) { ! // clip, but keep positive space this time since frustum planes are ! // the opposite to other cases (facing inwards rather than outwards) ! clip(fr.getFrustumPlane(i), false); } } *************** *** 918,922 **** } //----------------------------------------------------------------------- ! void ConvexBody::clip( const Plane& pl ) { if ( getPolygonCount() == 0 ) --- 906,910 ---- } //----------------------------------------------------------------------- ! void ConvexBody::clip( const Plane& pl, bool keepNegative ) { if ( getPolygonCount() == 0 ) *************** *** 956,961 **** // for each vertex check where it is situated in regard to the plane // three possibilities appear: ! // - side is POSITIVE: vertex will be clipped ! // - side is NEGATIVE: vertex will be untouched // - side is NOSIDE: vertex will be untouched Plane::Side *side = new Plane::Side[ vertexCount ]; --- 944,950 ---- // for each vertex check where it is situated in regard to the plane // three possibilities appear: ! Plane::Side clipSide = keepNegative ? Plane::POSITIVE_SIDE : Plane::NEGATIVE_SIDE; ! // - side is clipSide: vertex will be clipped ! // - side is !clipSide: vertex will be untouched // - side is NOSIDE: vertex will be untouched Plane::Side *side = new Plane::Side[ vertexCount ]; *************** *** 980,985 **** // case 1: both points inside (store next) ! if ( side[ iVertex ] != Plane::POSITIVE_SIDE && // NEGATIVE or NONE ! side[ iNextVertex ] != Plane::POSITIVE_SIDE ) // NEGATIVE or NONE { // keep the second --- 969,974 ---- // case 1: both points inside (store next) ! if ( side[ iVertex ] != clipSide && // NEGATIVE or NONE ! side[ iNextVertex ] != clipSide ) // NEGATIVE or NONE { // keep the second *************** *** 988,993 **** // case 3: inside -> outside (store intersection) ! else if ( side[ iVertex ] != Plane::POSITIVE_SIDE && ! side[ iNextVertex ] == Plane::POSITIVE_SIDE ) { // Do an intersection with the plane. We use a ray with a start point and a direction. --- 977,982 ---- // case 3: inside -> outside (store intersection) ! else if ( side[ iVertex ] != clipSide && ! side[ iNextVertex ] == clipSide ) { // Do an intersection with the plane. We use a ray with a start point and a direction. *************** *** 1014,1019 **** // case 4: outside -> inside (store intersection, store next) ! else if ( side[ iVertex ] == Plane::POSITIVE_SIDE && ! side[ iNextVertex ] != Plane::POSITIVE_SIDE ) { // Do an intersection with the plane. We use a ray with a start point and a direction. --- 1003,1008 ---- // case 4: outside -> inside (store intersection, store next) ! else if ( side[ iVertex ] == clipSide && ! side[ iNextVertex ] != clipSide ) { // Do an intersection with the plane. We use a ray with a start point and a direction. Index: OgreFrustum.cpp =================================================================== RCS file: /cvsroot/ogre/ogrenew/OgreMain/src/OgreFrustum.cpp,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** OgreFrustum.cpp 26 Nov 2006 16:07:23 -0000 1.41 --- OgreFrustum.cpp 2 Jan 2007 21:38:28 -0000 1.42 *************** *** 233,240 **** updateFrustumPlanes(); - // Get corners of the box - const Vector3* pCorners = bound.getAllCorners(); - - // For each plane, see if all points are on the negative side // If so, object is not visible --- 233,236 ---- *************** *** 245,256 **** continue; ! if (mFrustumPlanes[plane].getSide(pCorners[0]) == Plane::NEGATIVE_SIDE && ! mFrustumPlanes[plane].getSide(pCorners[1]) == Plane::NEGATIVE_SIDE && ! mFrustumPlanes[plane].getSide(pCorners[2]) == Plane::NEGATIVE_SIDE && ! mFrustumPlanes[plane].getSide(pCorners[3]) == Plane::NEGATIVE_SIDE && ! mFrustumPlanes[plane].getSide(pCorners[4]) == Plane::NEGATIVE_SIDE && ! mFrustumPlanes[plane].getSide(pCorners[5]) == Plane::NEGATIVE_SIDE && ! mFrustumPlanes[plane].getSide(pCorners[6]) == Plane::NEGATIVE_SIDE && ! mFrustumPlanes[plane].getSide(pCorners[7]) == Plane::NEGATIVE_SIDE) { // ALL corners on negative side therefore out of view --- 241,245 ---- continue; ! if (mFrustumPlanes[plane].getSide(bound) == Plane::NEGATIVE_SIDE) { // ALL corners on negative side therefore out of view Index: OgreMath.cpp =================================================================== RCS file: /cvsroot/ogre/ogrenew/OgreMain/src/OgreMath.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** OgreMath.cpp 23 Aug 2006 08:18:40 -0000 1.32 --- OgreMath.cpp 2 Jan 2007 21:38:28 -0000 1.33 *************** *** 860,880 **** if (box.isInfinite()) return true; ! // Get corners of the box ! const Vector3* pCorners = box.getAllCorners(); ! ! ! // Test which side of the plane the corners are ! // Intersection occurs when at least one corner is on the ! // opposite side to another ! Plane::Side lastSide = plane.getSide(pCorners[0]); ! for (int corner = 1; corner < 8; ++corner) ! { ! if (plane.getSide(pCorners[corner]) != lastSide) ! { ! return true; ! } ! } ! ! return false; } //----------------------------------------------------------------------- --- 860,864 ---- if (box.isInfinite()) return true; ! return (plane.getSide(box) == Plane::BOTH_SIDE); } //----------------------------------------------------------------------- Index: OgrePlane.cpp =================================================================== RCS file: /cvsroot/ogre/ogrenew/OgreMain/src/OgrePlane.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** OgrePlane.cpp 13 Sep 2006 17:25:38 -0000 1.13 --- OgrePlane.cpp 2 Jan 2007 21:38:28 -0000 1.14 *************** *** 2,6 **** ----------------------------------------------------------------------------- This source file is part of OGRE ! (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ --- 2,6 ---- ----------------------------------------------------------------------------- This source file is part of OGRE ! (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ *************** *** 32,93 **** namespace Ogre { ! //----------------------------------------------------------------------- ! Plane::Plane () ! { ! normal = Vector3::ZERO; ! d = 0.0; ! } ! //----------------------------------------------------------------------- ! Plane::Plane (const Plane& rhs) ! { ! normal = rhs.normal; ! d = rhs.d; ! } ! //----------------------------------------------------------------------- ! Plane::Plane (const Vector3& rkNormal, Real fConstant) ! { ! normal = rkNormal; ! d = -fConstant; ! } ! //----------------------------------------------------------------------- ! Plane::Plane (const Vector3& rkNormal, const Vector3& rkPoint) ! { ! normal = rkNormal; ! d = -rkNormal.dotProduct(rkPoint); ! } ! //----------------------------------------------------------------------- ! Plane::Plane (const Vector3& rkPoint0, const Vector3& rkPoint1, ! const Vector3& rkPoint2) ! { ! redefine(rkPoint0, rkPoint1, rkPoint2); ! } ! //----------------------------------------------------------------------- ! Real Plane::getDistance (const Vector3& rkPoint) const ! { ! return normal.dotProduct(rkPoint) + d; ! } ! //----------------------------------------------------------------------- ! Plane::Side Plane::getSide (const Vector3& rkPoint) const ! { ! Real fDistance = getDistance(rkPoint); ! if ( fDistance < 0.0 ) ! return Plane::NEGATIVE_SIDE; - if ( fDistance > 0.0 ) - return Plane::POSITIVE_SIDE; ! return Plane::NO_SIDE; ! } ! //----------------------------------------------------------------------- ! void Plane::redefine(const Vector3& rkPoint0, const Vector3& rkPoint1, ! const Vector3& rkPoint2) ! { ! Vector3 kEdge1 = rkPoint1 - rkPoint0; ! Vector3 kEdge2 = rkPoint2 - rkPoint0; ! normal = kEdge1.crossProduct(kEdge2); ! normal.normalise(); ! d = -normal.dotProduct(rkPoint0); ! } //----------------------------------------------------------------------- Vector3 Plane::projectVector(const Vector3& p) --- 32,153 ---- namespace Ogre { ! //----------------------------------------------------------------------- ! Plane::Plane () ! { ! normal = Vector3::ZERO; ! d = 0.0; ! } ! //----------------------------------------------------------------------- ! Plane::Plane (const Plane& rhs) ! { ! normal = rhs.normal; ! d = rhs.d; ! } ! //----------------------------------------------------------------------- ! Plane::Plane (const Vector3& rkNormal, Real fConstant) ! { ! normal = rkNormal; ! d = -fConstant; ! } ! //----------------------------------------------------------------------- ! Plane::Plane (const Vector3& rkNormal, const Vector3& rkPoint) ! { ! redefine(rkNormal, rkPoint); ! } ! //----------------------------------------------------------------------- ! Plane::Plane (const Vector3& rkPoint0, const Vector3& rkPoint1, ! const Vector3& rkPoint2) ! { ! redefine(rkPoint0, rkPoint1, rkPoint2); ! } ! //----------------------------------------------------------------------- ! Real Plane::getDistance (const Vector3& rkPoint) const ! { ! return normal.dotProduct(rkPoint) + d; ! } ! //----------------------------------------------------------------------- ! Plane::Side Plane::getSide (const Vector3& rkPoint) const ! { ! Real fDistance = getDistance(rkPoint); ! if ( fDistance < 0.0 ) ! return Plane::NEGATIVE_SIDE; ! ! if ( fDistance > 0.0 ) ! return Plane::POSITIVE_SIDE; ! ! return Plane::NO_SIDE; ! } ! //----------------------------------------------------------------------- ! Plane::Side Plane::getSide (const AxisAlignedBox& box) const ! { ! if (box.isNull()) ! return NO_SIDE; ! if (box.isInfinite()) ! return BOTH_SIDE; ! ! const Vector3& min = box.getMinimum(); ! const Vector3& max = box.getMaximum(); ! Plane::Side firstSide = getSide(min); // 0 min min min ! ! Vector3 currentCorner = min; ! Plane::Side currentSide; ! ! currentCorner.z = max.z; // 6 min min max ! currentSide = getSide(currentCorner); ! if(currentSide != firstSide) ! return BOTH_SIDE; ! ! currentCorner.y = max.y; // 5 min max max ! currentSide = getSide(currentCorner); ! if(currentSide != firstSide) ! return BOTH_SIDE; ! ! currentCorner.z = min.z; // 1 min max min ! currentSide = getSide(currentCorner); ! if(currentSide != firstSide) ! return BOTH_SIDE; ! ! currentCorner.x = max.x; // 2 max max min ! currentSide = getSide(currentCorner); ! if(currentSide != firstSide) ! return BOTH_SIDE; ! ! currentCorner.z = max.z; // 4 max max max ! currentSide = getSide(currentCorner); ! if(currentSide != firstSide) ! return BOTH_SIDE; ! ! currentCorner.y = min.y; // 7 max min max ! currentSide = getSide(currentCorner); ! if(currentSide != firstSide) ! return BOTH_SIDE; ! ! currentCorner.z = min.z; // 3 max min min ! currentSide = getSide(currentCorner); ! if(currentSide != firstSide) ! return BOTH_SIDE; ! ! return firstSide; ! } ! ! //----------------------------------------------------------------------- ! void Plane::redefine(const Vector3& rkPoint0, const Vector3& rkPoint1, ! const Vector3& rkPoint2) ! { ! Vector3 kEdge1 = rkPoint1 - rkPoint0; ! Vector3 kEdge2 = rkPoint2 - rkPoint0; ! normal = kEdge1.crossProduct(kEdge2); ! normal.normalise(); ! d = -normal.dotProduct(rkPoint0); ! } ! //----------------------------------------------------------------------- ! void Plane::redefine(const Vector3& rkNormal, const Vector3& rkPoint) ! { ! normal = rkNormal; ! d = -rkNormal.dotProduct(rkPoint); ! } //----------------------------------------------------------------------- Vector3 Plane::projectVector(const Vector3& p) *************** *** 108,115 **** } //----------------------------------------------------------------------- ! std::ostream& operator<< (std::ostream& o, Plane& p) ! { ! o << "Plane(normal=" << p.normal << ", d=" << p.d << ")"; ! return o; ! } } // namespace Ogre --- 168,175 ---- } //----------------------------------------------------------------------- ! std::ostream& operator<< (std::ostream& o, Plane& p) ! { ! o << "Plane(normal=" << p.normal << ", d=" << p.d << ")"; ! return o; ! } } // namespace Ogre Index: OgreShadowCameraSetupFocused.cpp =================================================================== RCS file: /cvsroot/ogre/ogrenew/OgreMain/src/OgreShadowCameraSetupFocused.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** OgreShadowCameraSetupFocused.cpp 28 Dec 2006 13:20:07 -0000 1.7 --- OgreShadowCameraSetupFocused.cpp 2 Jan 2007 21:38:28 -0000 1.8 *************** *** 548,562 **** // insert them into the list ! // ordering of the AAB points: ! // 1-----2 ! // /| /| ! // / | / | ! // 5-----4 | ! // | 0--|--3 ! // | / | / ! // |/ |/ ! // 6-----7 ! ! const Vector3 *aabPts = aabMax.getAllCorners(); // assemble the clipping planes --- 548,554 ---- // insert them into the list ! // min/max aab points for comparison ! const Vector3& min = aabMax.getMinimum(); ! const Vector3& max = aabMax.getMaximum(); // assemble the clipping planes *************** *** 564,589 **** // front ! pl[0].redefine(aabPts[4], aabPts[5], aabPts[6]); ! // back ! pl[1].redefine(aabPts[1], aabPts[2], aabPts[3]); ! // left ! pl[2].redefine(aabPts[1], aabPts[0], aabPts[6]); ! // right ! pl[3].redefine(aabPts[2], aabPts[4], aabPts[7]); ! // bottom ! pl[4].redefine(aabPts[0], aabPts[3], aabPts[7]); ! // top ! pl[5].redefine(aabPts[2], aabPts[1], aabPts[5]); - // min/max aab points for comparison - const Vector3& min = aabMax.getMinimum(); - const Vector3& max = aabMax.getMaximum(); - const size_t polyCount = body.getPolygonCount(); for (size_t iPoly = 0; iPoly < polyCount; ++iPoly) --- 556,572 ---- // front ! pl[0].redefine(Vector3::UNIT_Z, max); // back ! pl[1].redefine(Vector3::NEGATIVE_UNIT_Z, min); // left ! pl[2].redefine(Vector3::NEGATIVE_UNIT_X, min); // right ! pl[3].redefine(Vector3::UNIT_X, max); // bottom ! pl[4].redefine(Vector3::NEGATIVE_UNIT_Y, min); // top ! pl[5].redefine(Vector3::UNIT_Y, max); const size_t polyCount = body.getPolygonCount(); for (size_t iPoly = 0; iPoly < polyCount; ++iPoly) *************** *** 659,668 **** void FocusedShadowCameraSetup::PointListBody::addAAB(const AxisAlignedBox& aab) { ! const Vector3 *pts = aab.getAllCorners(); - for (size_t i = 0; i < 8; ++i) - { - this->addPoint(pts[ i ]); - } } //----------------------------------------------------------------------- --- 642,680 ---- void FocusedShadowCameraSetup::PointListBody::addAAB(const AxisAlignedBox& aab) { ! const Vector3& min = aab.getMinimum(); ! const Vector3& max = aab.getMaximum(); ! ! Vector3 currentVertex = min; ! // min min min ! addPoint(currentVertex); ! ! // min min max ! currentVertex.z = max.z; ! addPoint(currentVertex); ! ! // min max max ! currentVertex.y = max.y; ! addPoint(currentVertex); ! ! // min max min ! currentVertex.z = min.z; ! addPoint(currentVertex); ! ! // max max min ! currentVertex.x = max.x; ! addPoint(currentVertex); ! ! // max max max ! currentVertex.z = max.z; ! addPoint(currentVertex); ! ! // max min max ! currentVertex.y = min.y; ! addPoint(currentVertex); ! ! // max min min ! currentVertex.z = min.z; ! addPoint(currentVertex); } //----------------------------------------------------------------------- Index: OgreShadowCaster.cpp =================================================================== RCS file: /cvsroot/ogre/ogrenew/OgreMain/src/OgreShadowCaster.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** OgreShadowCaster.cpp 18 Dec 2006 17:49:13 -0000 1.30 --- OgreShadowCaster.cpp 2 Jan 2007 21:38:28 -0000 1.31 *************** *** 253,280 **** else { ! const Vector3* corners = box.getAllCorners(); ! Vector3 vmin, vmax; ! for (unsigned short i = 0; i < 8; ++i) ! { ! extrusionDir.x = corners[i].x - light.x; ! extrusionDir.y = corners[i].y - light.y; ! extrusionDir.z = corners[i].z - light.z; ! extrusionDir.normalise(); ! extrusionDir *= extrudeDist; ! Vector3 res = corners[i] + extrusionDir; ! if (i == 0) ! { ! vmin = res; ! vmax = res; ! } ! else ! { ! vmin.makeFloor(res); ! vmax.makeCeil(res); ! } ! } ! box.setExtents(vmin, vmax); } --- 253,323 ---- else { ! Vector3 oldMin, oldMax, currentCorner; ! // Getting the original values ! oldMin = box.getMinimum(); ! oldMax = box.getMaximum(); ! // Starting the box again with a null content ! box.setNull(); ! ! // merging all the extruded corners ! // 0 : min min min ! currentCorner = oldMin; ! extrusionDir.x = currentCorner.x - light.x; ! extrusionDir.y = currentCorner.y - light.y; ! extrusionDir.z = currentCorner.z - light.z; ! extrusionDir.normalise(); ! extrusionDir *= extrudeDist; ! box.merge(currentCorner + extrusionDir); ! // 6 : min min max ! // only z has changed ! currentCorner.z = oldMax.z; ! extrusionDir.z = currentCorner.z - light.z; ! extrusionDir.normalise(); ! extrusionDir *= extrudeDist; ! box.merge(currentCorner + extrusionDir); ! ! // 5 : min max max ! currentCorner.y = oldMax.y; ! extrusionDir.y = currentCorner.y - light.y; ! extrusionDir.normalise(); ! extrusionDir *= extrudeDist; ! box.merge(currentCorner + extrusionDir); ! ! // 1 : min max min ! currentCorner.z = oldMin.z; ! extrusionDir.z = currentCorner.z - light.z; ! extrusionDir.normalise(); ! extrusionDir *= extrudeDist; ! box.merge(currentCorner + extrusionDir); ! ! // 2 : max max min ! currentCorner.x = oldMax.x; ! extrusionDir.x = currentCorner.x - light.x; ! extrusionDir.normalise(); ! extrusionDir *= extrudeDist; ! box.merge(currentCorner + extrusionDir); ! ! // 4 : max max max ! currentCorner.z = oldMax.z; ! extrusionDir.z = currentCorner.z - light.z; ! extrusionDir.normalise(); ! extrusionDir *= extrudeDist; ! box.merge(currentCorner + extrusionDir); ! ! // 7 : max min max ! currentCorner.y = oldMin.y; ! extrusionDir.y = currentCorner.y - light.y; ! extrusionDir.normalise(); ! extrusionDir *= extrudeDist; ! box.merge(currentCorner + extrusionDir); ! ! // 3 : max min min ! currentCorner.z = oldMin.z; ! extrusionDir.z = currentCorner.z - light.z; ! extrusionDir.normalise(); ! extrusionDir *= extrudeDist; ! box.merge(currentCorner + extrusionDir); } ```