You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-13 13:31:48 +00:00
skip the first integration in physics bodies, fixes #2213
This commit is contained in:
@@ -380,6 +380,8 @@ void BodySW::set_space(SpaceSW *p_space){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
first_integration=true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BodySW::_compute_area_gravity_and_dampenings(const AreaSW *p_area) {
|
void BodySW::_compute_area_gravity_and_dampenings(const AreaSW *p_area) {
|
||||||
@@ -479,7 +481,7 @@ void BodySW::integrate_forces(real_t p_step) {
|
|||||||
do_motion=true;
|
do_motion=true;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!omit_force_integration) {
|
if (!omit_force_integration && !first_integration) {
|
||||||
//overriden by direct state query
|
//overriden by direct state query
|
||||||
|
|
||||||
Vector3 force=gravity*mass;
|
Vector3 force=gravity*mass;
|
||||||
@@ -512,6 +514,7 @@ void BodySW::integrate_forces(real_t p_step) {
|
|||||||
|
|
||||||
applied_force=Vector3();
|
applied_force=Vector3();
|
||||||
applied_torque=Vector3();
|
applied_torque=Vector3();
|
||||||
|
first_integration=false;
|
||||||
|
|
||||||
//motion=linear_velocity*p_step;
|
//motion=linear_velocity*p_step;
|
||||||
|
|
||||||
@@ -749,6 +752,7 @@ BodySW::BodySW() : CollisionObjectSW(TYPE_BODY), active_list(this), inertia_upda
|
|||||||
island_next=NULL;
|
island_next=NULL;
|
||||||
island_list_next=NULL;
|
island_list_next=NULL;
|
||||||
first_time_kinematic=false;
|
first_time_kinematic=false;
|
||||||
|
first_integration=false;
|
||||||
_set_static(false);
|
_set_static(false);
|
||||||
|
|
||||||
contact_count=0;
|
contact_count=0;
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ class BodySW : public CollisionObjectSW {
|
|||||||
bool omit_force_integration;
|
bool omit_force_integration;
|
||||||
bool active;
|
bool active;
|
||||||
|
|
||||||
|
bool first_integration;
|
||||||
|
|
||||||
bool continuous_cd;
|
bool continuous_cd;
|
||||||
bool can_sleep;
|
bool can_sleep;
|
||||||
bool first_time_kinematic;
|
bool first_time_kinematic;
|
||||||
|
|||||||
@@ -378,6 +378,7 @@ void Body2DSW::set_space(Space2DSW *p_space){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
first_integration=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Body2DSW::_compute_area_gravity_and_dampenings(const Area2DSW *p_area) {
|
void Body2DSW::_compute_area_gravity_and_dampenings(const Area2DSW *p_area) {
|
||||||
@@ -471,7 +472,7 @@ void Body2DSW::integrate_forces(real_t p_step) {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!omit_force_integration) {
|
if (!omit_force_integration && !first_integration) {
|
||||||
//overriden by direct state query
|
//overriden by direct state query
|
||||||
|
|
||||||
Vector2 force=gravity*mass;
|
Vector2 force=gravity*mass;
|
||||||
@@ -506,6 +507,7 @@ void Body2DSW::integrate_forces(real_t p_step) {
|
|||||||
|
|
||||||
//motion=linear_velocity*p_step;
|
//motion=linear_velocity*p_step;
|
||||||
|
|
||||||
|
first_integration=false;
|
||||||
biased_angular_velocity=0;
|
biased_angular_velocity=0;
|
||||||
biased_linear_velocity=Vector2();
|
biased_linear_velocity=Vector2();
|
||||||
|
|
||||||
@@ -681,6 +683,7 @@ Body2DSW::Body2DSW() : CollisionObject2DSW(TYPE_BODY), active_list(this), inerti
|
|||||||
gravity_scale=1.0;
|
gravity_scale=1.0;
|
||||||
using_one_way_cache=false;
|
using_one_way_cache=false;
|
||||||
one_way_collision_max_depth=0.1;
|
one_way_collision_max_depth=0.1;
|
||||||
|
first_integration=false;
|
||||||
|
|
||||||
still_time=0;
|
still_time=0;
|
||||||
continuous_cd_mode=Physics2DServer::CCD_MODE_DISABLED;
|
continuous_cd_mode=Physics2DServer::CCD_MODE_DISABLED;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ class Body2DSW : public CollisionObject2DSW {
|
|||||||
bool active;
|
bool active;
|
||||||
bool can_sleep;
|
bool can_sleep;
|
||||||
bool first_time_kinematic;
|
bool first_time_kinematic;
|
||||||
|
bool first_integration;
|
||||||
bool using_one_way_cache;
|
bool using_one_way_cache;
|
||||||
void _update_inertia();
|
void _update_inertia();
|
||||||
virtual void _shapes_changed();
|
virtual void _shapes_changed();
|
||||||
|
|||||||
Reference in New Issue
Block a user