summaryrefslogtreecommitdiff
path: root/servers/physics/shape_sw.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-09-02 23:13:40 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-09-02 23:13:40 -0300
commit1a2cb755e2d8b9d59178f36702f6dff7235b9088 (patch)
tree4a88f47c8b984522e36ac973accb34bdcb00363b /servers/physics/shape_sw.cpp
parent89fa70706f9166765c3ac3f799225a467800f065 (diff)
3D Physics and Other Stuff
-=-=-=-=-=-=-=-=-=-=-=-=-= -New Vehicle (Based on Bullet's RaycastVehicle) - Vehiclebody/VehicleWheel. Demo will come soon, old vehicle (CarBody) will go away soon too. -A lot of fixes to the 3D physics engine -Added KinematicBody with demo -Fixed the space query API for 2D (demo will come soon). 3D is WIP. -Fixed long-standing bug with body_enter/body_exit for Area and Area2D -Performance variables now includes physics (active bodies, collision pairs and islands) -Ability to see what's inside of instanced scenes! -Fixed Blend Shapes (no bs+skeleton yet) -Added an Android JavaClassWrapper singleton for using Android native classes directly from GDScript. This is very Alpha!
Diffstat (limited to 'servers/physics/shape_sw.cpp')
-rw-r--r--servers/physics/shape_sw.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp
index 1312b7da95..bd4be05bb9 100644
--- a/servers/physics/shape_sw.cpp
+++ b/servers/physics/shape_sw.cpp
@@ -928,8 +928,8 @@ void FaceShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supp
for (int i=0;i<3;i++) {
int nx=(i+1)%3;
- //if (i!=vert_support_idx && nx!=vert_support_idx)
- // continue;
+ if (i!=vert_support_idx && nx!=vert_support_idx)
+ continue;
// check if edge is valid as a support
float dot=(vertex[i]-vertex[nx]).normalized().dot(n);
@@ -951,8 +951,12 @@ bool FaceShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end,
bool c=Geometry::segment_intersects_triangle(p_begin,p_end,vertex[0],vertex[1],vertex[2],&r_result);
- if (c)
+ if (c) {
r_normal=Plane(vertex[0],vertex[1],vertex[2]).normal;
+ if (r_normal.dot(p_end-p_begin)>0) {
+ r_normal=-r_normal;
+ }
+ }
return c;
}
@@ -1070,13 +1074,15 @@ void ConcavePolygonShapeSW::_cull_segment(int p_idx,_SegmentCullParams *p_params
&res)) {
- float d=p_params->normal.dot(res) - p_params->normal.dot(p_params->from);
+ float d=p_params->dir.dot(res) - p_params->dir.dot(p_params->from);
//TODO, seems segmen/triangle intersection is broken :(
if (d>0 && d<p_params->min_d) {
p_params->min_d=d;
p_params->result=res;
p_params->normal=Plane(vertices[0],vertices[1],vertices[2]).normal;
+ if (p_params->normal.dot(p_params->dir)>0)
+ p_params->normal=-p_params->normal;
p_params->collisions++;
}
@@ -1107,7 +1113,7 @@ bool ConcavePolygonShapeSW::intersect_segment(const Vector3& p_begin,const Vecto
params.from=p_begin;
params.to=p_end;
params.collisions=0;
- params.normal=(p_end-p_begin).normalized();
+ params.dir=(p_end-p_begin).normalized();
params.faces=fr.ptr();
params.vertices=vr.ptr();