New and corrected are override modes.
This commit is contained in:
parent
7f96f0603e
commit
89efebbf56
|
@ -652,7 +652,7 @@ void Area2D::_bind_methods() {
|
|||
ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D")));
|
||||
|
||||
|
||||
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Replace"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
|
||||
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Combine-Replace,Replace,Replace-Combine"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
|
||||
ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point"));
|
||||
ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_gravity_distance_scale"),_SCS("get_gravity_distance_scale"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"gravity_vec"),_SCS("set_gravity_vector"),_SCS("get_gravity_vector"));
|
||||
|
|
|
@ -40,7 +40,9 @@ public:
|
|||
enum SpaceOverride {
|
||||
SPACE_OVERRIDE_DISABLED,
|
||||
SPACE_OVERRIDE_COMBINE,
|
||||
SPACE_OVERRIDE_REPLACE
|
||||
SPACE_OVERRIDE_COMBINE_REPLACE,
|
||||
SPACE_OVERRIDE_REPLACE,
|
||||
SPACE_OVERRIDE_REPLACE_COMBINE
|
||||
};
|
||||
private:
|
||||
|
||||
|
|
|
@ -579,7 +579,7 @@ void Area::_bind_methods() {
|
|||
ADD_SIGNAL( MethodInfo("area_enter",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
|
||||
ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area")));
|
||||
|
||||
ADD_PROPERTY( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Replace"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::INT,"space_override",PROPERTY_HINT_ENUM,"Disabled,Combine,Combine-Replace,Replace,Replace-Combine"),_SCS("set_space_override_mode"),_SCS("get_space_override_mode"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"gravity_point"),_SCS("set_gravity_is_point"),_SCS("is_gravity_a_point"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::REAL,"gravity_distance_scale", PROPERTY_HINT_RANGE,"0,1024,0.001"),_SCS("set_gravity_distance_scale"),_SCS("get_gravity_distance_scale"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::VECTOR3,"gravity_vec"),_SCS("set_gravity_vector"),_SCS("get_gravity_vector"));
|
||||
|
|
|
@ -40,7 +40,9 @@ public:
|
|||
enum SpaceOverride {
|
||||
SPACE_OVERRIDE_DISABLED,
|
||||
SPACE_OVERRIDE_COMBINE,
|
||||
SPACE_OVERRIDE_REPLACE
|
||||
SPACE_OVERRIDE_COMBINE_REPLACE,
|
||||
SPACE_OVERRIDE_REPLACE,
|
||||
SPACE_OVERRIDE_REPLACE_COMBINE
|
||||
};
|
||||
private:
|
||||
|
||||
|
|
|
@ -406,29 +406,41 @@ void BodySW::integrate_forces(real_t p_step) {
|
|||
return;
|
||||
|
||||
AreaSW *def_area = get_space()->get_default_area();
|
||||
AreaSW *damp_area = def_area;
|
||||
// AreaSW *damp_area = def_area;
|
||||
|
||||
ERR_FAIL_COND(!def_area);
|
||||
|
||||
int ac = areas.size();
|
||||
bool replace = false;
|
||||
bool stopped = false;
|
||||
gravity = Vector3(0,0,0);
|
||||
area_linear_damp = 0;
|
||||
area_angular_damp = 0;
|
||||
if (ac) {
|
||||
areas.sort();
|
||||
const AreaCMP *aa = &areas[0];
|
||||
damp_area = aa[ac-1].area;
|
||||
for(int i=ac-1;i>=0;i--) {
|
||||
_compute_area_gravity_and_dampenings(aa[i].area);
|
||||
if (aa[i].area->get_space_override_mode() == PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE) {
|
||||
replace = true;
|
||||
break;
|
||||
// damp_area = aa[ac-1].area;
|
||||
for(int i=ac-1;i>=0 && !stopped;i--) {
|
||||
PhysicsServer::AreaSpaceOverrideMode mode=aa[i].area->get_space_override_mode();
|
||||
switch (mode) {
|
||||
case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE:
|
||||
case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
|
||||
_compute_area_gravity_and_dampenings(aa[i].area);
|
||||
stopped = mode==PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
|
||||
} break;
|
||||
case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE:
|
||||
case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
|
||||
gravity = Vector3(0,0,0);
|
||||
area_angular_damp = 0;
|
||||
area_linear_damp = 0;
|
||||
_compute_area_gravity_and_dampenings(aa[i].area);
|
||||
stopped = mode==PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE;
|
||||
} break;
|
||||
default: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !replace ) {
|
||||
if( !stopped ) {
|
||||
_compute_area_gravity_and_dampenings(def_area);
|
||||
}
|
||||
|
||||
|
|
|
@ -395,6 +395,7 @@ void Body2DSW::_compute_area_gravity_and_dampenings(const Area2DSW *p_area) {
|
|||
|
||||
area_linear_damp += p_area->get_linear_damp();
|
||||
area_angular_damp += p_area->get_angular_damp();
|
||||
printf("%f\n",gravity.y);
|
||||
}
|
||||
|
||||
void Body2DSW::integrate_forces(real_t p_step) {
|
||||
|
@ -403,27 +404,39 @@ void Body2DSW::integrate_forces(real_t p_step) {
|
|||
return;
|
||||
|
||||
Area2DSW *def_area = get_space()->get_default_area();
|
||||
Area2DSW *damp_area = def_area;
|
||||
// Area2DSW *damp_area = def_area;
|
||||
ERR_FAIL_COND(!def_area);
|
||||
|
||||
int ac = areas.size();
|
||||
bool replace = false;
|
||||
bool stopped = false;
|
||||
gravity = Vector2(0,0);
|
||||
area_angular_damp = 0;
|
||||
area_linear_damp = 0;
|
||||
if (ac) {
|
||||
areas.sort();
|
||||
const AreaCMP *aa = &areas[0];
|
||||
damp_area = aa[ac-1].area;
|
||||
for(int i=ac-1;i>=0;i--) {
|
||||
_compute_area_gravity_and_dampenings(aa[i].area);
|
||||
if (aa[i].area->get_space_override_mode() == Physics2DServer::AREA_SPACE_OVERRIDE_REPLACE) {
|
||||
replace = true;
|
||||
break;
|
||||
// damp_area = aa[ac-1].area;
|
||||
for(int i=ac-1;i>=0 && !stopped;i--) {
|
||||
Physics2DServer::AreaSpaceOverrideMode mode=aa[i].area->get_space_override_mode();
|
||||
switch (mode) {
|
||||
case Physics2DServer::AREA_SPACE_OVERRIDE_COMBINE:
|
||||
case Physics2DServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: {
|
||||
_compute_area_gravity_and_dampenings(aa[i].area);
|
||||
stopped = mode==Physics2DServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE;
|
||||
} break;
|
||||
case Physics2DServer::AREA_SPACE_OVERRIDE_REPLACE:
|
||||
case Physics2DServer::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: {
|
||||
gravity = Vector2(0,0);
|
||||
area_angular_damp = 0;
|
||||
area_linear_damp = 0;
|
||||
_compute_area_gravity_and_dampenings(aa[i].area);
|
||||
stopped = mode==Physics2DServer::AREA_SPACE_OVERRIDE_REPLACE;
|
||||
} break;
|
||||
default: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
if( !replace ) {
|
||||
if( !stopped ) {
|
||||
_compute_area_gravity_and_dampenings(def_area);
|
||||
}
|
||||
gravity*=gravity_scale;
|
||||
|
@ -501,7 +514,7 @@ void Body2DSW::integrate_forces(real_t p_step) {
|
|||
_update_shapes_with_motion(motion);
|
||||
}
|
||||
|
||||
damp_area=NULL; // clear the area, so it is set in the next frame
|
||||
// damp_area=NULL; // clear the area, so it is set in the next frame
|
||||
def_area=NULL; // clear the area, so it is set in the next frame
|
||||
contact_count=0;
|
||||
|
||||
|
|
|
@ -663,9 +663,11 @@ void Physics2DServer::_bind_methods() {
|
|||
BIND_CONSTANT( AREA_PARAM_ANGULAR_DAMP);
|
||||
BIND_CONSTANT( AREA_PARAM_PRIORITY );
|
||||
|
||||
BIND_CONSTANT( AREA_SPACE_OVERRIDE_COMBINE );
|
||||
BIND_CONSTANT( AREA_SPACE_OVERRIDE_DISABLED );
|
||||
BIND_CONSTANT( AREA_SPACE_OVERRIDE_COMBINE );
|
||||
BIND_CONSTANT( AREA_SPACE_OVERRIDE_COMBINE_REPLACE );
|
||||
BIND_CONSTANT( AREA_SPACE_OVERRIDE_REPLACE );
|
||||
BIND_CONSTANT( AREA_SPACE_OVERRIDE_REPLACE_COMBINE );
|
||||
|
||||
BIND_CONSTANT( BODY_MODE_STATIC );
|
||||
BIND_CONSTANT( BODY_MODE_KINEMATIC );
|
||||
|
|
|
@ -325,7 +325,9 @@ public:
|
|||
enum AreaSpaceOverrideMode {
|
||||
AREA_SPACE_OVERRIDE_DISABLED,
|
||||
AREA_SPACE_OVERRIDE_COMBINE,
|
||||
AREA_SPACE_OVERRIDE_COMBINE_REPLACE, // Combines, then discards all subsequent calculations
|
||||
AREA_SPACE_OVERRIDE_REPLACE,
|
||||
AREA_SPACE_OVERRIDE_REPLACE_COMBINE // Discards all previous calculations, then keeps combining
|
||||
};
|
||||
|
||||
virtual void area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode)=0;
|
||||
|
|
|
@ -693,9 +693,11 @@ void PhysicsServer::_bind_methods() {
|
|||
BIND_CONSTANT( AREA_PARAM_ANGULAR_DAMP );
|
||||
BIND_CONSTANT( AREA_PARAM_PRIORITY );
|
||||
|
||||
BIND_CONSTANT( AREA_SPACE_OVERRIDE_COMBINE );
|
||||
BIND_CONSTANT( AREA_SPACE_OVERRIDE_DISABLED );
|
||||
BIND_CONSTANT( AREA_SPACE_OVERRIDE_COMBINE );
|
||||
BIND_CONSTANT( AREA_SPACE_OVERRIDE_COMBINE_REPLACE );
|
||||
BIND_CONSTANT( AREA_SPACE_OVERRIDE_REPLACE );
|
||||
BIND_CONSTANT( AREA_SPACE_OVERRIDE_REPLACE_COMBINE );
|
||||
|
||||
BIND_CONSTANT( BODY_MODE_STATIC );
|
||||
BIND_CONSTANT( BODY_MODE_KINEMATIC );
|
||||
|
|
|
@ -318,7 +318,9 @@ public:
|
|||
enum AreaSpaceOverrideMode {
|
||||
AREA_SPACE_OVERRIDE_DISABLED,
|
||||
AREA_SPACE_OVERRIDE_COMBINE,
|
||||
AREA_SPACE_OVERRIDE_COMBINE_REPLACE,
|
||||
AREA_SPACE_OVERRIDE_REPLACE,
|
||||
AREA_SPACE_OVERRIDE_REPLACE_COMBINE
|
||||
};
|
||||
|
||||
virtual void area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode)=0;
|
||||
|
|
Loading…
Reference in New Issue