diff options
Diffstat (limited to 'extern/solid/src/broad')
-rw-r--r-- | extern/solid/src/broad/BP_C-api.cpp | 77 | ||||
-rw-r--r-- | extern/solid/src/broad/BP_Endpoint.h | 108 | ||||
-rw-r--r-- | extern/solid/src/broad/BP_EndpointList.cpp | 237 | ||||
-rw-r--r-- | extern/solid/src/broad/BP_EndpointList.h | 109 | ||||
-rw-r--r-- | extern/solid/src/broad/BP_Proxy.cpp | 120 | ||||
-rw-r--r-- | extern/solid/src/broad/BP_Proxy.h | 78 | ||||
-rw-r--r-- | extern/solid/src/broad/BP_ProxyList.h | 69 | ||||
-rw-r--r-- | extern/solid/src/broad/BP_Scene.cpp | 151 | ||||
-rw-r--r-- | extern/solid/src/broad/BP_Scene.h | 79 | ||||
-rw-r--r-- | extern/solid/src/broad/Makefile | 41 |
10 files changed, 0 insertions, 1069 deletions
diff --git a/extern/solid/src/broad/BP_C-api.cpp b/extern/solid/src/broad/BP_C-api.cpp deleted file mode 100644 index 43e1172927b..00000000000 --- a/extern/solid/src/broad/BP_C-api.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * SOLID - Software Library for Interference Detection - * - * Copyright (C) 2001-2003 Dtecta. All rights reserved. - * - * This library may be distributed under the terms of the Q Public License - * (QPL) as defined by Trolltech AS of Norway and appearing in the file - * LICENSE.QPL included in the packaging of this file. - * - * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Commercial use or any other use of this library not covered by either - * the QPL or the GPL requires an additional license from Dtecta. - * Please contact info@dtecta.com for enquiries about the terms of commercial - * use of this library. - */ - -#include "SOLID_broad.h" - -#include "BP_Scene.h" -#include "BP_Proxy.h" - -BP_SceneHandle BP_CreateScene(void *client_data, - BP_Callback beginOverlap, - BP_Callback endOverlap) -{ - return (BP_SceneHandle)new BP_Scene(client_data, - beginOverlap, - endOverlap); -} - - -void BP_DestroyScene(BP_SceneHandle scene) -{ - delete (BP_Scene *)scene; -} - - -BP_ProxyHandle BP_CreateProxy(BP_SceneHandle scene, void *object, - const DT_Vector3 min, const DT_Vector3 max) -{ - return (BP_ProxyHandle) - ((BP_Scene *)scene)->createProxy(object, min, max); -} - - -void BP_DestroyProxy(BP_SceneHandle scene, BP_ProxyHandle proxy) -{ - ((BP_Scene *)scene)->destroyProxy((BP_Proxy *)proxy); -} - - - -void BP_SetBBox(BP_ProxyHandle proxy, const DT_Vector3 min, const DT_Vector3 max) -{ - ((BP_Proxy *)proxy)->setBBox(min, max); -} - -void *BP_RayCast(BP_SceneHandle scene, - BP_RayCastCallback objectRayCast, - void *client_data, - const DT_Vector3 source, - const DT_Vector3 target, - DT_Scalar *lambda) -{ - return ((BP_Scene *)scene)->rayCast(objectRayCast, - client_data, - source, target, - *lambda); -} - diff --git a/extern/solid/src/broad/BP_Endpoint.h b/extern/solid/src/broad/BP_Endpoint.h deleted file mode 100644 index 8de6e67ce65..00000000000 --- a/extern/solid/src/broad/BP_Endpoint.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * SOLID - Software Library for Interference Detection - * - * Copyright (C) 2001-2003 Dtecta. All rights reserved. - * - * This library may be distributed under the terms of the Q Public License - * (QPL) as defined by Trolltech AS of Norway and appearing in the file - * LICENSE.QPL included in the packaging of this file. - * - * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Commercial use or any other use of this library not covered by either - * the QPL or the GPL requires an additional license from Dtecta. - * Please contact info@dtecta.com for enquiries about the terms of commercial - * use of this library. - */ - -#ifndef BP_ENDPOINT_H -#define BP_ENDPOINT_H - -#include "SOLID_types.h" - -class BP_Proxy; - -class BP_Link { -public: - BP_Link() {} - explicit BP_Link(BP_Proxy *proxy) : - m_proxy(proxy) - {} - - DT_Index m_index; - DT_Count m_count; - BP_Proxy *m_proxy; -}; - -typedef unsigned int Uint32; - -class BP_Endpoint { -public: - enum { - MINIMUM = 0x00000000, - MAXIMUM = 0x80000000, - TYPEBIT = 0x00000001 - }; - - BP_Endpoint() {} - BP_Endpoint(DT_Scalar pos, Uint32 type, BP_Link *link) - : m_link(link) - { - setPos(pos, type); - } - - DT_Scalar getPos() const { return m_pos; } - DT_Index& getIndex() const { return m_link->m_index; } - DT_Count& getCount() const { return m_link->m_count; } - BP_Proxy *getProxy() const { return m_link->m_proxy; } - - DT_Index getEndIndex() const { return (m_link + 1)->m_index; } - - Uint32 getType() const - { - return (m_bits & TYPEBIT) ? (~m_bits & MAXIMUM) : (m_bits & MAXIMUM); - } - - void setPos(DT_Scalar pos, Uint32 type) - { - m_pos = pos; - if ((m_bits & MAXIMUM) == type) - { - m_bits &= ~TYPEBIT; - } - else - { - m_bits |= TYPEBIT; - } - } - -private: - union { - DT_Scalar m_pos; - Uint32 m_bits; - }; - BP_Link *m_link; -}; - -inline bool operator<(const BP_Endpoint& a, const BP_Endpoint& b) -{ - return a.getPos() < b.getPos(); -} - -#endif - - - - - - - - - - diff --git a/extern/solid/src/broad/BP_EndpointList.cpp b/extern/solid/src/broad/BP_EndpointList.cpp deleted file mode 100644 index aa094ffeb0a..00000000000 --- a/extern/solid/src/broad/BP_EndpointList.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* - * SOLID - Software Library for Interference Detection - * - * Copyright (C) 2001-2003 Dtecta. All rights reserved. - * - * This library may be distributed under the terms of the Q Public License - * (QPL) as defined by Trolltech AS of Norway and appearing in the file - * LICENSE.QPL included in the packaging of this file. - * - * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Commercial use or any other use of this library not covered by either - * the QPL or the GPL requires an additional license from Dtecta. - * Please contact info@dtecta.com for enquiries about the terms of commercial - * use of this library. - */ - -#include <float.h> -#include <algorithm> - -#include "BP_EndpointList.h" -#include "BP_Scene.h" -#include "BP_Proxy.h" -#include "BP_ProxyList.h" - -DT_Index BP_EndpointList::stab(const BP_Endpoint& pos, BP_ProxyList& proxies) const -{ - DT_Index result = std::upper_bound(begin(), end(), pos) - begin(); - - if (result != 0) - { - DT_Index i = result - 1; - DT_Count count = (*this)[i].getCount(); - while (count) - { - const BP_Endpoint& endpoint = (*this)[i]; - if (endpoint.getType() == BP_Endpoint::MINIMUM && - pos < (*this)[endpoint.getEndIndex()]) - { - proxies.add(endpoint.getProxy()); - --count; - } - assert(i != 0 || count == 0); - --i; - } - } - return result; -} - -DT_Scalar BP_EndpointList::nextLambda(DT_Index& index, - DT_Scalar source, - DT_Scalar delta) const -{ - if (delta != 0.0f) - { - if (delta < 0.0f) - { - if (index != 0) - { - return ((*this)[--index].getPos() - source) / delta; - } - } - else - { - if (index != size()) - { - return ((*this)[index++].getPos() - source) / delta; - } - } - } - return FLT_MAX; -} - - -void BP_EndpointList::range(const BP_Endpoint& min, - const BP_Endpoint& max, - DT_Index& first, DT_Index& last, - BP_ProxyList& proxies) const -{ - first = stab(min, proxies); - last = std::upper_bound(begin(), end(), max) - begin(); - - DT_Index i; - for (i = first; i != last; ++i) - { - const BP_Endpoint& endpoint = (*this)[i]; - if (endpoint.getType() == BP_Endpoint::MINIMUM) - { - proxies.add(endpoint.getProxy()); - } - } -} - -void BP_EndpointList::addInterval(const BP_Endpoint& min, - const BP_Endpoint& max, - BP_ProxyList& proxies) -{ - assert(invariant()); - DT_Index first, last; - range(min, max, first, last, proxies); - insert(begin() + last, max); - insert(begin() + first, min); - ++last; - - (*this)[first].getCount() = first != 0 ? (*this)[first - 1].getCount() : 0; - (*this)[last].getCount() = (*this)[last - 1].getCount(); - - - DT_Index i; - for (i = first; i != last; ++i) - { - ++(*this)[i].getCount(); - (*this)[i].getIndex() = i; - } - for (; i != size(); ++i) - { - (*this)[i].getIndex() = i; - } - - assert(invariant()); -} - -void BP_EndpointList::removeInterval(DT_Index first, DT_Index last, - BP_ProxyList& proxies) -{ - assert(invariant()); - - BP_Endpoint min = (*this)[first]; - BP_Endpoint max = (*this)[last]; - - erase(begin() + last); - erase(begin() + first); - --last; - - DT_Index i; - for (i = first; i != last; ++i) - { - --(*this)[i].getCount(); - (*this)[i].getIndex() = i; - } - for (; i != size(); ++i) - { - (*this)[i].getIndex() = i; - } - - range(min, max, first, last, proxies); - - assert(invariant()); -} - -void BP_EndpointList::move(DT_Index index, DT_Scalar pos, Uint32 type, - BP_Scene& scene, T_Overlap overlap) -{ - assert(invariant()); - - BP_Endpoint endpoint = (*this)[index]; - DT_Scalar delta = pos - endpoint.getPos(); - - if (delta != DT_Scalar(0.0)) - { - endpoint.setPos(pos, type); - if (delta < DT_Scalar(0.0)) - { - while (index != 0 && endpoint < (*this)[index - 1]) - { - (*this)[index] = (*this)[index - 1]; - (*this)[index].getIndex() = index; - encounters((*this)[index], endpoint, scene, overlap); - --index; - } - } - else - { - DT_Index last = size() - 1; - while (index != last && (*this)[index + 1] < endpoint) - { - (*this)[index] = (*this)[index + 1]; - (*this)[index].getIndex() = index; - encounters(endpoint, (*this)[index], scene, overlap); - ++index; - } - } - (*this)[index] = endpoint; - (*this)[index].getIndex() = index; - } - - assert(invariant()); -} - -void BP_EndpointList::encounters(const BP_Endpoint& a, const BP_Endpoint& b, - BP_Scene& scene, T_Overlap overlap) -{ - assert(a.getProxy() != b.getProxy()); - - if (a.getType() != b.getType()) - { - if (a.getType() == BP_Endpoint::MAXIMUM) - { - if (overlap(*a.getProxy(), *b.getProxy())) - { - scene.callBeginOverlap(a.getProxy()->getObject(), - b.getProxy()->getObject()); - } - ++a.getCount(); - ++b.getCount(); - } - else - { - if (overlap(*a.getProxy(), *b.getProxy())) - { - scene.callEndOverlap(a.getProxy()->getObject(), - b.getProxy()->getObject()); - } - --a.getCount(); - --b.getCount(); - } - } - else - { - if (a.getType() == BP_Endpoint::MAXIMUM) - { - --a.getCount(); - ++b.getCount(); - } - else - { - ++a.getCount(); - --b.getCount(); - } - } -} diff --git a/extern/solid/src/broad/BP_EndpointList.h b/extern/solid/src/broad/BP_EndpointList.h deleted file mode 100644 index 6154991ed3d..00000000000 --- a/extern/solid/src/broad/BP_EndpointList.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * SOLID - Software Library for Interference Detection - * - * Copyright (C) 2001-2003 Dtecta. All rights reserved. - * - * This library may be distributed under the terms of the Q Public License - * (QPL) as defined by Trolltech AS of Norway and appearing in the file - * LICENSE.QPL included in the packaging of this file. - * - * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Commercial use or any other use of this library not covered by either - * the QPL or the GPL requires an additional license from Dtecta. - * Please contact info@dtecta.com for enquiries about the terms of commercial - * use of this library. - */ - -#ifndef BP_ENDPOINTLIST_H -#define BP_ENDPOINTLIST_H - -//#define PARANOID - -#include <vector> - -#include "BP_Endpoint.h" -#include "BP_ProxyList.h" - -class BP_Scene; - -typedef bool (*T_Overlap)(const BP_Proxy& a, const BP_Proxy& b); - -class BP_EndpointList : public std::vector<BP_Endpoint> { -public: - BP_EndpointList() {} - - DT_Index stab(const BP_Endpoint& pos, BP_ProxyList& proxies) const; - - DT_Index stab(DT_Scalar pos, BP_ProxyList& proxies) const - { - return stab(BP_Endpoint(pos, BP_Endpoint::MINIMUM, 0), proxies); - } - - - void range(const BP_Endpoint& min, const BP_Endpoint& max, - DT_Index& first, DT_Index& last, BP_ProxyList& proxies) const; - - void range(DT_Scalar lb, DT_Scalar ub, DT_Index& first, DT_Index& last, BP_ProxyList& proxies) const - { - range(BP_Endpoint(lb, BP_Endpoint::MINIMUM, 0), - BP_Endpoint(ub, BP_Endpoint::MAXIMUM, 0), - first, last, proxies); - } - - void addInterval(const BP_Endpoint& min, const BP_Endpoint& max, BP_ProxyList& proxies); - void removeInterval(DT_Index first, DT_Index last, BP_ProxyList& proxies); - - void move(DT_Index index, DT_Scalar pos, Uint32 type, BP_Scene& scene, T_Overlap overlap); - - DT_Scalar nextLambda(DT_Index& index, DT_Scalar source, DT_Scalar target) const; - - -private: - void encounters(const BP_Endpoint& a, const BP_Endpoint& b, - BP_Scene& scene, T_Overlap overlap); - - -#ifdef PARANOID - bool invariant() const - { - DT_Count count = 0; - DT_Index i; - for (i = 0; i != size(); ++i) - { - const BP_Endpoint& endpoint = (*this)[i]; - - if (endpoint.getType() == BP_Endpoint::MINIMUM) - { - ++count; - } - else - { - --count; - } - if (endpoint.getCount() != count) - { - return false; - } - if (endpoint.getIndex() != i) - { - return false; - } - } - return true; - } -#else - bool invariant() const { return true; } -#endif - -}; - - - -#endif diff --git a/extern/solid/src/broad/BP_Proxy.cpp b/extern/solid/src/broad/BP_Proxy.cpp deleted file mode 100644 index e8007df240d..00000000000 --- a/extern/solid/src/broad/BP_Proxy.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * SOLID - Software Library for Interference Detection - * - * Copyright (C) 2001-2003 Dtecta. All rights reserved. - * - * This library may be distributed under the terms of the Q Public License - * (QPL) as defined by Trolltech AS of Norway and appearing in the file - * LICENSE.QPL included in the packaging of this file. - * - * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Commercial use or any other use of this library not covered by either - * the QPL or the GPL requires an additional license from Dtecta. - * Please contact info@dtecta.com for enquiries about the terms of commercial - * use of this library. - */ - -#include <new> - -#include "BP_Proxy.h" -#include "BP_Scene.h" - -BP_Proxy::BP_Proxy(void *object, - BP_Scene& scene) - : m_object(object), - m_scene(scene) -{ - int i; - for (i = 0; i < 3; ++i) - { - new (&m_interval[i]) BP_Interval(this); - } -} - -void BP_Proxy::add(const DT_Vector3 min, - const DT_Vector3 max, - BP_ProxyList& proxies) -{ - int i; - for (i = 0; i < 3; ++i) - { - m_scene.getList(i).addInterval( - BP_Endpoint(min[i], BP_Endpoint::MINIMUM, &m_interval[i].m_min), - BP_Endpoint(max[i], BP_Endpoint::MAXIMUM, &m_interval[i].m_max), - proxies); - } -} - -void BP_Proxy::remove(BP_ProxyList& proxies) -{ - int i; - for (i = 0; i < 3; ++i) - { - m_scene.getList(i).removeInterval( - m_interval[i].m_min.m_index, - m_interval[i].m_max.m_index, - proxies); - } -} - -DT_Scalar BP_Proxy::getMin(int i) const -{ - return m_scene.getList(i)[m_interval[i].m_min.m_index].getPos(); -} - -DT_Scalar BP_Proxy::getMax(int i) const -{ - return m_scene.getList(i)[m_interval[i].m_max.m_index].getPos(); -} - -bool overlapXY(const BP_Proxy& a, const BP_Proxy& b) -{ - return a.getMin(0) <= b.getMax(0) && b.getMin(0) <= a.getMax(0) && - a.getMin(1) <= b.getMax(1) && b.getMin(1) <= a.getMax(1); -} - -bool overlapXZ(const BP_Proxy& a, const BP_Proxy& b) -{ - return a.getMin(0) <= b.getMax(0) && b.getMin(0) <= a.getMax(0) && - a.getMin(2) <= b.getMax(2) && b.getMin(2) <= a.getMax(2); -} - -bool overlapYZ(const BP_Proxy& a, const BP_Proxy& b) -{ - return a.getMin(1) <= b.getMax(1) && b.getMin(1) <= a.getMax(1) && - a.getMin(2) <= b.getMax(2) && b.getMin(2) <= a.getMax(2); -} - -void BP_Proxy::setBBox(const DT_Vector3 min, const DT_Vector3 max) -{ - static T_Overlap overlap[3] = { overlapYZ, overlapXZ, overlapXY }; - - int i; - for (i = 0; i < 3; ++i) - { - if (min[i] > getMax(i)) - { - m_scene.getList(i).move(m_interval[i].m_max.m_index, max[i], - BP_Endpoint::MAXIMUM, m_scene, overlap[i]); - m_scene.getList(i).move(m_interval[i].m_min.m_index, min[i], - BP_Endpoint::MINIMUM, m_scene, overlap[i]); - } - else - { - m_scene.getList(i).move(m_interval[i].m_min.m_index, min[i], - BP_Endpoint::MINIMUM, m_scene, overlap[i]); - m_scene.getList(i).move(m_interval[i].m_max.m_index, max[i], - BP_Endpoint::MAXIMUM, m_scene, overlap[i]); - } - } -} - - - diff --git a/extern/solid/src/broad/BP_Proxy.h b/extern/solid/src/broad/BP_Proxy.h deleted file mode 100644 index b4500ddca44..00000000000 --- a/extern/solid/src/broad/BP_Proxy.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SOLID - Software Library for Interference Detection - * - * Copyright (C) 2001-2003 Dtecta. All rights reserved. - * - * This library may be distributed under the terms of the Q Public License - * (QPL) as defined by Trolltech AS of Norway and appearing in the file - * LICENSE.QPL included in the packaging of this file. - * - * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Commercial use or any other use of this library not covered by either - * the QPL or the GPL requires an additional license from Dtecta. - * Please contact info@dtecta.com for enquiries about the terms of commercial - * use of this library. - */ - -#ifndef BP_PROXY_H -#define BP_PROXY_H - -#include "BP_Endpoint.h" -#include "BP_ProxyList.h" - -class BP_Interval { -public: - BP_Interval() {} - BP_Interval(BP_Proxy *proxy) : - m_min(proxy), - m_max(proxy) - {} - - BP_Link m_min; - BP_Link m_max; -}; - -class BP_Scene; - -class BP_Proxy { -public: - BP_Proxy(void *object, BP_Scene& scene); - - void add(const DT_Vector3 min, - const DT_Vector3 max, - BP_ProxyList& proxies); - - void remove(BP_ProxyList& proxies); - - void setBBox(const DT_Vector3 min, const DT_Vector3 max); - - void *getObject() { return m_object; } - - DT_Scalar getMin(int i) const; - DT_Scalar getMax(int i) const; - -private: - BP_Interval m_interval[3]; - void *m_object; - BP_Scene& m_scene; -}; - -inline bool BP_overlap(const BP_Proxy *a, const BP_Proxy *b) -{ - return a->getMin(0) <= b->getMax(0) && b->getMin(0) <= a->getMax(0) && - a->getMin(1) <= b->getMax(1) && b->getMin(1) <= a->getMax(1) && - a->getMin(2) <= b->getMax(2) && b->getMin(2) <= a->getMax(2); -} - -#endif - - - - diff --git a/extern/solid/src/broad/BP_ProxyList.h b/extern/solid/src/broad/BP_ProxyList.h deleted file mode 100644 index 2f449777d2d..00000000000 --- a/extern/solid/src/broad/BP_ProxyList.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SOLID - Software Library for Interference Detection - * - * Copyright (C) 2001-2003 Dtecta. All rights reserved. - * - * This library may be distributed under the terms of the Q Public License - * (QPL) as defined by Trolltech AS of Norway and appearing in the file - * LICENSE.QPL included in the packaging of this file. - * - * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Commercial use or any other use of this library not covered by either - * the QPL or the GPL requires an additional license from Dtecta. - * Please contact info@dtecta.com for enquiries about the terms of commercial - * use of this library. - */ - -#ifndef BP_PROXYLIST_H -#define BP_PROXYLIST_H - -#include <assert.h> - -#include <vector> -#include <algorithm> -#include <utility> - -class BP_Proxy; - -typedef std::pair<BP_Proxy *, unsigned int> BP_ProxyEntry; - -inline bool operator<(const BP_ProxyEntry& a, const BP_ProxyEntry& b) -{ - return a.first < b.first; -} - -class BP_ProxyList : public std::vector<BP_ProxyEntry> { -public: - BP_ProxyList(size_t n = 20) : std::vector<BP_ProxyEntry>(n) {} - - iterator add(BP_Proxy *proxy) - { - BP_ProxyEntry entry = std::make_pair(proxy, (unsigned int)0); - iterator it = std::lower_bound(begin(), end(), entry); - if (it == end() || (*it).first != proxy) - { - it = insert(it, entry); - } - ++(*it).second; - return it; - } - - void remove(BP_Proxy *proxy) - { - BP_ProxyEntry entry = std::make_pair(proxy, (unsigned int)0); - iterator it = std::lower_bound(begin(), end(), entry); - if (it != end() && (*it).first == proxy && --(*it).second == 0) - { - erase(it); - } - } -}; - -#endif diff --git a/extern/solid/src/broad/BP_Scene.cpp b/extern/solid/src/broad/BP_Scene.cpp deleted file mode 100644 index c0cd83ba311..00000000000 --- a/extern/solid/src/broad/BP_Scene.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * SOLID - Software Library for Interference Detection - * - * Copyright (C) 2001-2003 Dtecta. All rights reserved. - * - * This library may be distributed under the terms of the Q Public License - * (QPL) as defined by Trolltech AS of Norway and appearing in the file - * LICENSE.QPL included in the packaging of this file. - * - * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Commercial use or any other use of this library not covered by either - * the QPL or the GPL requires an additional license from Dtecta. - * Please contact info@dtecta.com for enquiries about the terms of commercial - * use of this library. - */ - -#include "BP_Scene.h" -#include "BP_Proxy.h" - -#include <algorithm> - -BP_Proxy *BP_Scene::createProxy(void *object, - const DT_Vector3 min, - const DT_Vector3 max) -{ - BP_Proxy *proxy = new BP_Proxy(object, *this); - - proxy->add(min, max, m_proxies); - - BP_ProxyList::iterator it; - for (it = m_proxies.begin(); it != m_proxies.end(); ++it) - { - if ((*it).second == 3) - { - callBeginOverlap(proxy->getObject(), (*it).first->getObject()); - } - } - - m_proxies.clear(); - - return proxy; -} - -void BP_Scene::destroyProxy(BP_Proxy *proxy) -{ - proxy->remove(m_proxies); - - BP_ProxyList::iterator it; - for (it = m_proxies.begin(); it != m_proxies.end(); ++it) - { - if ((*it).second == 3) - { - callEndOverlap(proxy->getObject(), (*it).first->getObject()); - } - } - - m_proxies.clear(); - - delete proxy; -} - -void *BP_Scene::rayCast(BP_RayCastCallback objectRayCast, - void *client_data, - const DT_Vector3 source, - const DT_Vector3 target, - DT_Scalar& lambda) const -{ - void *client_object = 0; - - DT_Index index[3]; - index[0] = m_endpointList[0].stab(source[0], m_proxies); - index[1] = m_endpointList[1].stab(source[1], m_proxies); - index[2] = m_endpointList[2].stab(source[2], m_proxies); - - BP_ProxyList::iterator it; - for (it = m_proxies.begin(); it != m_proxies.end(); ++it) - { - if ((*it).second == 3 && - (*objectRayCast)(client_data, (*it).first->getObject(), source, target, &lambda)) - { - client_object = (*it).first->getObject(); - } - } - - DT_Vector3 delta; - delta[0] = target[0] - source[0]; - delta[1] = target[1] - source[1]; - delta[2] = target[2] - source[2]; - - DT_Vector3 lambdas; - lambdas[0] = m_endpointList[0].nextLambda(index[0], source[0], delta[0]); - lambdas[1] = m_endpointList[1].nextLambda(index[1], source[1], delta[1]); - lambdas[2] = m_endpointList[2].nextLambda(index[2], source[2], delta[2]); - int closest = lambdas[0] < lambdas[1] ? (lambdas[0] < lambdas[2] ? 0 : 2) : (lambdas[1] < lambdas[2] ? 1 : 2); - - while (lambdas[closest] < lambda) - { - if (delta[closest] < 0.0f) - { - const BP_Endpoint& endpoint = m_endpointList[closest][index[closest]]; - - if (endpoint.getType() == BP_Endpoint::MAXIMUM) - { - it = m_proxies.add(endpoint.getProxy()); - if ((*it).second == 3 && - (*objectRayCast)(client_data, (*it).first->getObject(), source, target, &lambda)) - { - client_object = (*it).first->getObject(); - } - } - else - { - m_proxies.remove(endpoint.getProxy()); - } - } - else - { - const BP_Endpoint& endpoint = m_endpointList[closest][index[closest] - 1]; - - if (endpoint.getType() == BP_Endpoint::MINIMUM) - { - it = m_proxies.add(endpoint.getProxy()); - if ((*it).second == 3 && - (*objectRayCast)(client_data, (*it).first->getObject(), source, target, &lambda)) - { - client_object = (*it).first->getObject(); - } - } - else - { - m_proxies.remove(endpoint.getProxy()); - } - } - - lambdas[closest] = m_endpointList[closest].nextLambda(index[closest], source[closest], delta[closest]); - closest = lambdas[0] < lambdas[1] ? (lambdas[0] < lambdas[2] ? 0 : 2) : (lambdas[1] < lambdas[2] ? 1 : 2); - } - - m_proxies.clear(); - - return client_object; -} - - diff --git a/extern/solid/src/broad/BP_Scene.h b/extern/solid/src/broad/BP_Scene.h deleted file mode 100644 index ef55374c43b..00000000000 --- a/extern/solid/src/broad/BP_Scene.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * SOLID - Software Library for Interference Detection - * - * Copyright (C) 2001-2003 Dtecta. All rights reserved. - * - * This library may be distributed under the terms of the Q Public License - * (QPL) as defined by Trolltech AS of Norway and appearing in the file - * LICENSE.QPL included in the packaging of this file. - * - * This library may be distributed and/or modified under the terms of the - * GNU General Public License (GPL) version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * This library is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Commercial use or any other use of this library not covered by either - * the QPL or the GPL requires an additional license from Dtecta. - * Please contact info@dtecta.com for enquiries about the terms of commercial - * use of this library. - */ - -#ifndef BP_SCENE_H -#define BP_SCENE_H - -#include <SOLID_broad.h> - -#include "BP_EndpointList.h" -#include "BP_ProxyList.h" - -class BP_Proxy; - -class BP_Scene { -public: - BP_Scene(void *client_data, - BP_Callback beginOverlap, - BP_Callback endOverlap) - : m_client_data(client_data), - m_beginOverlap(beginOverlap), - m_endOverlap(endOverlap), - m_proxies(20) - {} - - ~BP_Scene() {} - - BP_Proxy *createProxy(void *object, - const DT_Vector3 min, - const DT_Vector3 max); - - void destroyProxy(BP_Proxy *proxy); - - void *rayCast(BP_RayCastCallback objectRayCast, - void *client_data, - const DT_Vector3 source, - const DT_Vector3 target, - DT_Scalar& lambda) const; - - void callBeginOverlap(void *object1, void *object2) - { - (*m_beginOverlap)(m_client_data, object1, object2); - } - - void callEndOverlap(void *object1, void *object2) - { - (*m_endOverlap)(m_client_data, object1, object2); - } - - BP_EndpointList& getList(int i) { return m_endpointList[i]; } - -private: - void *m_client_data; - BP_Callback m_beginOverlap; - BP_Callback m_endOverlap; - BP_EndpointList m_endpointList[3]; - mutable BP_ProxyList m_proxies; -}; - -#endif diff --git a/extern/solid/src/broad/Makefile b/extern/solid/src/broad/Makefile deleted file mode 100644 index ce10e5f0bcf..00000000000 --- a/extern/solid/src/broad/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# -# $Id$ -# -# ***** BEGIN GPL LICENSE BLOCK ***** -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. -# All rights reserved. -# -# The Original Code is: all of this file. -# -# Contributor(s): none yet. -# -# ***** END GPL LICENSE BLOCK ***** -# -# - -LIBNAME = solid_broad -DIR = $(OCGDIR)/extern/$(LIBNAME) - -CCFLAGS += $(LEVEL_1_CPP_WARNINGS) - -CPPFLAGS += -I../../include -I$(NAN_QHULL)/include -CPPFLAGS += -DQHULL -DUSE_DOUBLES - -include nan_compile.mk - - |