You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-19 14:31:59 +00:00
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!
This commit is contained in:
@@ -1538,6 +1538,70 @@ CarWheelSpatialGizmo::CarWheelSpatialGizmo(CarWheel* p_car_wheel){
|
||||
}
|
||||
|
||||
|
||||
/////
|
||||
|
||||
|
||||
void VehicleWheelSpatialGizmo::redraw() {
|
||||
|
||||
clear();
|
||||
|
||||
|
||||
Vector<Vector3> points;
|
||||
|
||||
float r = car_wheel->get_radius();
|
||||
const int skip=10;
|
||||
for(int i=0;i<=360;i+=skip) {
|
||||
|
||||
float ra=Math::deg2rad(i);
|
||||
float rb=Math::deg2rad(i+skip);
|
||||
Point2 a = Vector2(Math::sin(ra),Math::cos(ra))*r;
|
||||
Point2 b = Vector2(Math::sin(rb),Math::cos(rb))*r;
|
||||
|
||||
points.push_back(Vector3(0,a.x,a.y));
|
||||
points.push_back(Vector3(0,b.x,b.y));
|
||||
|
||||
const int springsec=4;
|
||||
|
||||
for(int j=0;j<springsec;j++) {
|
||||
float t = car_wheel->get_suspension_rest_length()*5;
|
||||
points.push_back(Vector3(a.x,i/360.0*t/springsec+j*(t/springsec),a.y)*0.2);
|
||||
points.push_back(Vector3(b.x,(i+skip)/360.0*t/springsec+j*(t/springsec),b.y)*0.2);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//travel
|
||||
points.push_back(Vector3(0,0,0));
|
||||
points.push_back(Vector3(0,car_wheel->get_suspension_rest_length(),0));
|
||||
|
||||
//axis
|
||||
points.push_back(Vector3(r*0.2,car_wheel->get_suspension_rest_length(),0));
|
||||
points.push_back(Vector3(-r*0.2,car_wheel->get_suspension_rest_length(),0));
|
||||
//axis
|
||||
points.push_back(Vector3(r*0.2,0,0));
|
||||
points.push_back(Vector3(-r*0.2,0,0));
|
||||
|
||||
//forward line
|
||||
points.push_back(Vector3(0,-r,0));
|
||||
points.push_back(Vector3(0,-r,r*2));
|
||||
points.push_back(Vector3(0,-r,r*2));
|
||||
points.push_back(Vector3(r*2*0.2,-r,r*2*0.8));
|
||||
points.push_back(Vector3(0,-r,r*2));
|
||||
points.push_back(Vector3(-r*2*0.2,-r,r*2*0.8));
|
||||
|
||||
add_lines(points,SpatialEditorGizmos::singleton->car_wheel_material);
|
||||
add_collision_segments(points);
|
||||
|
||||
}
|
||||
|
||||
VehicleWheelSpatialGizmo::VehicleWheelSpatialGizmo(VehicleWheel* p_car_wheel){
|
||||
|
||||
set_spatial_node(p_car_wheel);
|
||||
car_wheel=p_car_wheel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///
|
||||
|
||||
@@ -2292,6 +2356,11 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) {
|
||||
Ref<CarWheelSpatialGizmo> misg = memnew( CarWheelSpatialGizmo(p_spatial->cast_to<CarWheel>()) );
|
||||
return misg;
|
||||
}
|
||||
if (p_spatial->cast_to<VehicleWheel>()) {
|
||||
|
||||
Ref<VehicleWheelSpatialGizmo> misg = memnew( VehicleWheelSpatialGizmo(p_spatial->cast_to<VehicleWheel>()) );
|
||||
return misg;
|
||||
}
|
||||
|
||||
return Ref<SpatialEditorGizmo>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user