int PhysicsServerSW::joint_get_solver_priority(RID p_joint) const{ JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND_V(!joint,0); return joint->get_priority(); }
PhysicsServer::JointType PhysicsServerSW::joint_get_type(RID p_joint) const { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND_V(!joint,JOINT_PIN); return joint->get_type(); }
bool PhysicsServerSW::hinge_joint_get_flag(RID p_joint,HingeJointFlag p_flag) const{ JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND_V(!joint,false); ERR_FAIL_COND_V(joint->get_type()!=JOINT_HINGE,false); HingeJointSW *hinge_joint = static_cast<HingeJointSW*>(joint); return hinge_joint->get_flag(p_flag); }
Vector3 PhysicsServerSW::pin_joint_get_local_b(RID p_joint) const { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND_V(!joint, Vector3()); ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, Vector3()); PinJointSW *pin_joint = static_cast<PinJointSW *>(joint); return pin_joint->get_position_b(); }
void PhysicsServerSW::pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_PIN); PinJointSW *pin_joint = static_cast<PinJointSW *>(joint); pin_joint->set_pos_b(p_B); }
real_t PhysicsServerSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_PIN, 0); PinJointSW *pin_joint = static_cast<PinJointSW *>(joint); return pin_joint->get_param(p_param); }
void PhysicsServerSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_PIN); PinJointSW *pin_joint = static_cast<PinJointSW *>(joint); pin_joint->set_param(p_param, p_value); }
void PhysicsServerSW::hinge_joint_set_flag(RID p_joint, HingeJointFlag p_flag, bool p_value) { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_HINGE); HingeJointSW *hinge_joint = static_cast<HingeJointSW *>(joint); hinge_joint->set_flag(p_flag, p_value); }
real_t PhysicsServerSW::hinge_joint_get_param(RID p_joint, HingeJointParam p_param) const { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND_V(!joint, 0); ERR_FAIL_COND_V(joint->get_type() != JOINT_HINGE, 0); HingeJointSW *hinge_joint = static_cast<HingeJointSW *>(joint); return hinge_joint->get_param(p_param); }
void PhysicsServerSW::hinge_joint_set_param(RID p_joint, HingeJointParam p_param, real_t p_value) { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type() != JOINT_HINGE); HingeJointSW *hinge_joint = static_cast<HingeJointSW *>(joint); hinge_joint->set_param(p_param, p_value); }
void PhysicsServerSW::slider_joint_set_param(RID p_joint,SliderJointParam p_param, float p_value){ JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type()!=JOINT_SLIDER); SliderJointSW *slider_joint = static_cast<SliderJointSW*>(joint); slider_joint->set_param(p_param,p_value); }
float PhysicsServerSW::cone_twist_joint_get_param(RID p_joint,ConeTwistJointParam p_param) const { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND_V(!joint,0); ERR_FAIL_COND_V(joint->get_type()!=JOINT_CONE_TWIST,0); ConeTwistJointSW *cone_twist_joint = static_cast<ConeTwistJointSW*>(joint); return cone_twist_joint->get_param(p_param); }
void PhysicsServerSW::generic_6dof_joint_set_flag(RID p_joint,Vector3::Axis p_axis,G6DOFJointAxisFlag p_flag, bool p_enable){ JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type()!=JOINT_6DOF); Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW*>(joint); generic_6dof_joint->set_flag(p_axis,p_flag,p_enable); }
bool PhysicsServerSW::generic_6dof_joint_get_flag(RID p_joint,Vector3::Axis p_axis,G6DOFJointAxisFlag p_flag){ JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND_V(!joint,false); ERR_FAIL_COND_V(joint->get_type()!=JOINT_6DOF,false); Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW*>(joint); return generic_6dof_joint->get_flag(p_axis,p_flag); }
void PhysicsServerSW::generic_6dof_joint_set_param(RID p_joint,Vector3::Axis p_axis,G6DOFJointAxisParam p_param, float p_value){ JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type()!=JOINT_6DOF); Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW*>(joint); generic_6dof_joint->set_param(p_axis,p_param,p_value); }
float PhysicsServerSW::generic_6dof_joint_get_param(RID p_joint,Vector3::Axis p_axis,G6DOFJointAxisParam p_param){ JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND_V(!joint,0); ERR_FAIL_COND_V(joint->get_type()!=JOINT_6DOF,0); Generic6DOFJointSW *generic_6dof_joint = static_cast<Generic6DOFJointSW*>(joint); return generic_6dof_joint->get_param(p_axis,p_param); }
void PhysicsServerSW::cone_twist_joint_set_param(RID p_joint,ConeTwistJointParam p_param, float p_value) { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND(!joint); ERR_FAIL_COND(joint->get_type()!=JOINT_CONE_TWIST); ConeTwistJointSW *cone_twist_joint = static_cast<ConeTwistJointSW*>(joint); cone_twist_joint->set_param(p_param,p_value); }
float PhysicsServerSW::slider_joint_get_param(RID p_joint,SliderJointParam p_param) const{ JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND_V(!joint,0); ERR_FAIL_COND_V(joint->get_type()!=JOINT_CONE_TWIST,0); SliderJointSW *slider_joint = static_cast<SliderJointSW*>(joint); return slider_joint->get_param(p_param); }
real_t PhysicsServerSW::damped_string_joint_get_param(RID p_joint, DampedStringParam p_param) const { JointSW *j = joint_owner.get(p_joint); ERR_FAIL_COND_V(!j,0); ERR_FAIL_COND_V(j->get_type()!=JOINT_DAMPED_SPRING,0); DampedSpringJointSW *dsj = static_cast<DampedSpringJointSW*>(j); return dsj->get_param(p_param); }
void PhysicsServerSW::damped_string_joint_set_param(RID p_joint, DampedStringParam p_param, real_t p_value) { JointSW *j = joint_owner.get(p_joint); ERR_FAIL_COND(!j); ERR_FAIL_COND(j->get_type()!=JOINT_DAMPED_SPRING); DampedSpringJointSW *dsj = static_cast<DampedSpringJointSW*>(j); dsj->set_param(p_param,p_value); }
void PhysicsServerSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND(!joint); switch(p_param) { case JOINT_PARAM_BIAS: joint->set_bias(p_value); break; case JOINT_PARAM_MAX_BIAS: joint->set_max_bias(p_value); break; case JOINT_PARAM_MAX_FORCE: joint->set_max_force(p_value); break; } }
RID PhysicsServerSW::damped_spring_joint_create(const Vector3& p_anchor_a,const Vector3& p_anchor_b,RID p_body_a,RID p_body_b) { BodySW *A=body_owner.get(p_body_a); ERR_FAIL_COND_V(!A,RID()); BodySW *B=body_owner.get(p_body_b); ERR_FAIL_COND_V(!B,RID()); JointSW *joint = memnew( DampedSpringJointSW(p_anchor_a,p_anchor_b,A,B) ); RID self = joint_owner.make_rid(joint); joint->set_self(self); return self; }
RID PhysicsServerSW::groove_joint_create(const Vector3& p_a_groove1,const Vector3& p_a_groove2, const Vector3& p_b_anchor, RID p_body_a,RID p_body_b) { BodySW *A=body_owner.get(p_body_a); ERR_FAIL_COND_V(!A,RID()); BodySW *B=body_owner.get(p_body_b); ERR_FAIL_COND_V(!B,RID()); JointSW *joint = memnew( GrooveJointSW(p_a_groove1,p_a_groove2,p_b_anchor,A,B) ); RID self = joint_owner.make_rid(joint); joint->set_self(self); return self; }
RID PhysicsServerSW::pin_joint_create(const Vector3& p_pos,RID p_body_a,RID p_body_b) { BodySW *A=body_owner.get(p_body_a); ERR_FAIL_COND_V(!A,RID()); BodySW *B=NULL; if (body_owner.owns(p_body_b)) { B=body_owner.get(p_body_b); ERR_FAIL_COND_V(!B,RID()); } JointSW *joint = memnew( PinJointSW(p_pos,A,B) ); RID self = joint_owner.make_rid(joint); joint->set_self(self); return self; }
void PhysicsServerSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND(!joint); joint->disable_collisions_between_bodies(p_disable); if (2 == joint->get_body_count()) { BodySW *body_a = *joint->get_body_ptr(); BodySW *body_b = *(joint->get_body_ptr() + 1); if (p_disable) { body_add_collision_exception(body_a->get_self(), body_b->get_self()); body_add_collision_exception(body_b->get_self(), body_a->get_self()); } else { body_remove_collision_exception(body_a->get_self(), body_b->get_self()); body_remove_collision_exception(body_b->get_self(), body_a->get_self()); } } }
RID PhysicsServerSW::joint_create_pin(RID p_body_A,const Vector3& p_local_A,RID p_body_B,const Vector3& p_local_B) { BodySW *body_A = body_owner.get(p_body_A); ERR_FAIL_COND_V(!body_A,RID()); if (!p_body_B.is_valid()) { ERR_FAIL_COND_V(!body_A->get_space(),RID()); p_body_B=body_A->get_space()->get_static_global_body(); } BodySW *body_B = body_owner.get(p_body_B); ERR_FAIL_COND_V(!body_B,RID()); ERR_FAIL_COND_V(body_A==body_B,RID()); JointSW *joint = memnew( PinJointSW(body_A,p_local_A,body_B,p_local_B) ); RID rid = joint_owner.make_rid(joint); joint->set_self(rid); return rid; }
RID PhysicsServerSW::joint_create_generic_6dof(RID p_body_A,const Transform& p_local_frame_A,RID p_body_B,const Transform& p_local_frame_B) { BodySW *body_A = body_owner.get(p_body_A); ERR_FAIL_COND_V(!body_A,RID()); if (!p_body_B.is_valid()) { ERR_FAIL_COND_V(!body_A->get_space(),RID()); p_body_B=body_A->get_space()->get_static_global_body(); } BodySW *body_B = body_owner.get(p_body_B); ERR_FAIL_COND_V(!body_B,RID()); ERR_FAIL_COND_V(body_A==body_B,RID()); JointSW *joint = memnew( Generic6DOFJointSW(body_A,body_B,p_local_frame_A,p_local_frame_B,true) ); RID rid = joint_owner.make_rid(joint); joint->set_self(rid); return rid; }
void PhysicsServerSW::free(RID p_rid) { if (shape_owner.owns(p_rid)) { ShapeSW *shape = shape_owner.get(p_rid); while(shape->get_owners().size()) { ShapeOwnerSW *so=shape->get_owners().front()->key(); so->remove_shape(shape); } shape_owner.free(p_rid); memdelete(shape); } else if (body_owner.owns(p_rid)) { BodySW *body = body_owner.get(p_rid); // if (body->get_state_query()) // _clear_query(body->get_state_query()); // if (body->get_direct_state_query()) // _clear_query(body->get_direct_state_query()); body->set_space(NULL); while( body->get_shape_count() ) { body->remove_shape(0); } while (body->get_constraint_map().size()) { RID self = body->get_constraint_map().front()->key()->get_self(); ERR_FAIL_COND(!self.is_valid()); free(self); } body_owner.free(p_rid); memdelete(body); } else if (area_owner.owns(p_rid)) { AreaSW *area = area_owner.get(p_rid); // if (area->get_monitor_query()) // _clear_query(area->get_monitor_query()); area->set_space(NULL); while( area->get_shape_count() ) { area->remove_shape(0); } area_owner.free(p_rid); memdelete(area); } else if (space_owner.owns(p_rid)) { SpaceSW *space = space_owner.get(p_rid); while(space->get_objects().size()) { CollisionObjectSW *co = (CollisionObjectSW *)space->get_objects().front()->get(); co->set_space(NULL); } active_spaces.erase(space); free(space->get_default_area()->get_self()); free(space->get_static_global_body()); space_owner.free(p_rid); memdelete(space); } else if (joint_owner.owns(p_rid)) { JointSW *joint = joint_owner.get(p_rid); for(int i=0;i<joint->get_body_count();i++) { joint->get_body_ptr()[i]->remove_constraint(joint); } joint_owner.free(p_rid); memdelete(joint); } else { ERR_EXPLAIN("Invalid ID"); ERR_FAIL(); } };
void PhysicsServerSW::joint_set_solver_priority(RID p_joint,int p_priority) { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND(!joint); joint->set_priority(p_priority); }
bool PhysicsServerSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const { JointSW *joint = joint_owner.get(p_joint); ERR_FAIL_COND_V(!joint, true); return joint->is_disabled_collisions_between_bodies(); }