summaryrefslogtreecommitdiff
path: root/servers/physics
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-04-26 13:03:01 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-04-26 13:03:01 -0300
commit81f36b768d661b8bc69968c5bf823b8d9a747d41 (patch)
treecbe178d99e2f9ae2cbec5caa1f037973bde4136d /servers/physics
parent972af0b0cbe1e67470d6a520233dd1f58f8ae02c (diff)
fixes crash related to empty concavecollisionshape, fixes #1709
Diffstat (limited to 'servers/physics')
-rw-r--r--servers/physics/shape_sw.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp
index 6b90b904f4..fabfa88ee5 100644
--- a/servers/physics/shape_sw.cpp
+++ b/servers/physics/shape_sw.cpp
@@ -997,6 +997,11 @@ DVector<Vector3> ConcavePolygonShapeSW::get_faces() const {
void ConcavePolygonShapeSW::project_range(const Vector3& p_normal, const Transform& p_transform, real_t &r_min, real_t &r_max) const {
int count=vertices.size();
+ if (count==0) {
+ r_min=0;
+ r_max=0;
+ return;
+ }
DVector<Vector3>::Read r=vertices.read();
const Vector3 *vptr=r.ptr();
@@ -1016,6 +1021,9 @@ Vector3 ConcavePolygonShapeSW::get_support(const Vector3& p_normal) const {
int count=vertices.size();
+ if (count==0)
+ return Vector3();
+
DVector<Vector3>::Read r=vertices.read();
const Vector3 *vptr=r.ptr();
@@ -1103,6 +1111,9 @@ void ConcavePolygonShapeSW::_cull_segment(int p_idx,_SegmentCullParams *p_params
bool ConcavePolygonShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const {
+ if (faces.size()==0)
+ return false;
+
// unlock data
DVector<Face>::Read fr=faces.read();
DVector<Vector3>::Read vr=vertices.read();
@@ -1171,6 +1182,8 @@ void ConcavePolygonShapeSW::_cull(int p_idx,_CullParams *p_params) const {
void ConcavePolygonShapeSW::cull(const AABB& p_local_aabb,Callback p_callback,void* p_userdata) const {
// make matrix local to concave
+ if (faces.size()==0)
+ return;
AABB local_aabb=p_local_aabb;