diff options
Diffstat (limited to 'servers/physics/shape_sw.cpp')
-rw-r--r-- | servers/physics/shape_sw.cpp | 119 |
1 files changed, 3 insertions, 116 deletions
diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp index b4004c8c94..f02ff03fcf 100644 --- a/servers/physics/shape_sw.cpp +++ b/servers/physics/shape_sw.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,9 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "shape_sw.h" + #include "geometry.h" #include "quick_hull.h" #include "sort.h" + #define _POINT_SNAP 0.001953125 #define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.0002 #define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.9998 @@ -1473,119 +1475,6 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) { PoolVector<Vector3>::Read r = p_faces.read(); const Vector3 *facesr = r.ptr(); -#if 0 - Map<Vector3,int> point_map; - List<Face> face_list; - - - for(int i=0;i<src_face_count;i++) { - - Face3 faceaux; - - for(int j=0;j<3;j++) { - - faceaux.vertex[j]=facesr[i*3+j].snapped(_POINT_SNAP); - //faceaux.vertex[j]=facesr[i*3+j];//facesr[i*3+j].snapped(_POINT_SNAP); - } - - ERR_CONTINUE( faceaux.is_degenerate() ); - - Face face; - - for(int j=0;j<3;j++) { - - - Map<Vector3,int>::Element *E=point_map.find(faceaux.vertex[j]); - if (E) { - - face.indices[j]=E->value(); - } else { - - face.indices[j]=point_map.size(); - point_map.insert(faceaux.vertex[j],point_map.size()); - - } - } - - face_list.push_back(face); - } - - vertices.resize( point_map.size() ); - - PoolVector<Vector3>::Write vw = vertices.write(); - Vector3 *verticesw=vw.ptr(); - - AABB _aabb; - - for( Map<Vector3,int>::Element *E=point_map.front();E;E=E->next()) { - - if (E==point_map.front()) { - _aabb.pos=E->key(); - } else { - - _aabb.expand_to(E->key()); - } - verticesw[E->value()]=E->key(); - } - - point_map.clear(); // not needed anymore - - faces.resize(face_list.size()); - PoolVector<Face>::Write w = faces.write(); - Face *facesw=w.ptr(); - - int fc=0; - - for( List<Face>::Element *E=face_list.front();E;E=E->next()) { - - facesw[fc++]=E->get(); - } - - face_list.clear(); - - - PoolVector<_VolumeSW_BVH_Element> bvh_array; - bvh_array.resize( fc ); - - PoolVector<_VolumeSW_BVH_Element>::Write bvhw = bvh_array.write(); - _VolumeSW_BVH_Element *bvh_arrayw=bvhw.ptr(); - - - for(int i=0;i<fc;i++) { - - AABB face_aabb; - face_aabb.pos=verticesw[facesw[i].indices[0]]; - face_aabb.expand_to( verticesw[facesw[i].indices[1]] ); - face_aabb.expand_to( verticesw[facesw[i].indices[2]] ); - - bvh_arrayw[i].face_index=i; - bvh_arrayw[i].aabb=face_aabb; - bvh_arrayw[i].center=face_aabb.pos+face_aabb.size*0.5; - - } - - w=PoolVector<Face>::Write(); - vw=PoolVector<Vector3>::Write(); - - - int count=0; - _VolumeSW_BVH *bvh_tree=_volume_sw_build_bvh(bvh_arrayw,fc,count); - - ERR_FAIL_COND(count==0); - - bvhw=PoolVector<_VolumeSW_BVH_Element>::Write(); - - bvh.resize( count+1 ); - - PoolVector<BVH>::Write bvhw2 = bvh.write(); - BVH*bvh_arrayw2=bvhw2.ptr(); - - int idx=0; - _fill_bvh(bvh_tree,bvh_arrayw2,idx); - - set_aabb(_aabb); - -#else PoolVector<_VolumeSW_BVH_Element> bvh_array; bvh_array.resize(src_face_count); @@ -1638,8 +1527,6 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) { _fill_bvh(bvh_tree, bvh_arrayw2, idx); configure(_aabb); // this type of shape has no margin - -#endif } void ConcavePolygonShapeSW::set_data(const Variant &p_data) { |