[flatland-cvs] flatland/flatland bsd-license.txt,NONE,1.1 flatland.h,1.2,1.3 quad-circle.cpp,1.2,1.3
Status: Alpha
Brought to you by:
prideout
From: Philip R. <pri...@us...> - 2005-07-03 20:00:59
|
Update of /cvsroot/flatland/flatland/flatland In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27049/flatland Modified Files: flatland.h quad-circle.cpp vector.cpp vector.h Added Files: bsd-license.txt Removed Files: license-bsd.txt Log Message: Nuked dependency on GLU. Fixed spelling error "Southernmost" in complex.cpp. Added World::IsCorrupt() method for detecting singularities. Fixed a singularity that was sometimes seen with the catapult. Renamed license-bsd.txt to bsd-license.txt. Fixed aliasing in wheel spokes in complex-demo by using linear filtering. Index: quad-circle.cpp =================================================================== RCS file: /cvsroot/flatland/flatland/flatland/quad-circle.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** quad-circle.cpp 27 Feb 2005 22:16:32 -0000 1.2 --- quad-circle.cpp 3 Jul 2005 20:00:51 -0000 1.3 *************** *** 97,105 **** qq.y = dot(t, b); r = p - qq; ! float depth = c.Radius() - r.length(); if (depth < 0) return; ! r.normalize(); contacts.AddContact(qq + q.Center(), -r, depth); } --- 97,111 ---- qq.y = dot(t, b); r = p - qq; ! ! float distance = r.length(); ! float depth = c.Radius() - distance; if (depth < 0) return; ! if (distance) ! r.normalize(); ! else ! r = vec2(1, 0); ! contacts.AddContact(qq + q.Center(), -r, depth); } Index: vector.h =================================================================== RCS file: /cvsroot/flatland/flatland/flatland/vector.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** vector.h 27 Feb 2005 22:16:32 -0000 1.2 --- vector.h 3 Jul 2005 20:00:51 -0000 1.3 *************** *** 9,12 **** --- 9,13 ---- { const float pi = 3.1415926535897932384626433832795; + bool is_nan(float f); struct vec2; Index: flatland.h =================================================================== RCS file: /cvsroot/flatland/flatland/flatland/flatland.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** flatland.h 27 Feb 2005 05:04:57 -0000 1.2 --- flatland.h 3 Jul 2005 20:00:50 -0000 1.3 *************** *** 160,163 **** --- 160,164 ---- Body BodyCreate(); template<class S> void GenerateContacts(const S& space); + template<class S> bool IsCorrupt(const S& space) const; int ContactCount() const { return contactCount; } void SetCFM(float); *************** *** 238,241 **** --- 239,279 ---- } + /// Corruption detection in a scene. + // + /// IsCorrupt is a template function that takes any object that acts + /// like an STL container of pointers. + /// The given container does not need to be an actual STL container; it only needs to have these properties: + /// - Container::const_iterator + /// - Container::begin() + /// - Container::end() + /// The objects in the container must have a GetObject() method. + template<class Container> + bool World::IsCorrupt(const Container& space) const + { + typename Container::const_iterator o; + for (o = space.begin(); o != space.end(); ++o) + { + Object* object = (*o)->GetObject(); + if (!object) + continue; + + Body body = object->GetBody(); + if (!body) + continue; + + const dReal* lvel = dBodyGetLinearVel(body); + const dReal* avel = dBodyGetAngularVel(body); + + if (is_nan(lvel[0])) return true; + if (is_nan(lvel[1])) return true; + if (is_nan(lvel[2])) return true; + if (is_nan(avel[0])) return true; + if (is_nan(avel[1])) return true; + if (is_nan(avel[2])) return true; + } + return false; + } + + template<class G> Dynamic<G>::Dynamic(G* g, Body b) : geometry(g), body(b) --- license-bsd.txt DELETED --- Index: vector.cpp =================================================================== RCS file: /cvsroot/flatland/flatland/flatland/vector.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** vector.cpp 27 Feb 2005 22:16:32 -0000 1.2 --- vector.cpp 3 Jul 2005 20:00:51 -0000 1.3 *************** *** 13,14 **** --- 13,44 ---- vec2 vec2::rotate(float d) const { return rotate(vec2(cosf(d2r * d), sinf(d2r * d))); } float vec2::length() const { return sqrtf(dot(*this, *this)); } + + + // returns true for IEEE floats that are infinity or a not-a-number + bool Flatland::is_nan(float f) + { + unsigned long bits = *((unsigned long*) &f); + + // quiet -NaN + if (bits >= 0xffc00001 && bits <= 0xffffffff) return true; + + // indeterminate + if (bits == 0xffc00000) return true; + + // signaling -NaN + if (bits >= 0xff800001 && bits <= 0xffbfffff) return true; + + // minus infinity + if (bits == 0xff800000) return true; + + // positive infinity + if (bits == 0x7f800000) return true; + + // signaling +NaN + if (bits >= 0x7f800001 && bits <= 0x7fbfffff) return true; + + // signaling +NaN + if (bits >= 0x7fc00000 && bits <= 0x7fffffff) return true; + + return false; + } --- NEW FILE: bsd-license.txt --- This is the BSD-style license for Flatland ------------------------------------------ Flatland Copyright (c) 2005, Philip Rideout. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the names of Flatland's copyright owner nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |