validate_target
This commit is contained in:
parent
dd0efe66fe
commit
f7fc1ca70b
|
|
@ -114,7 +114,7 @@ end_group() {
|
|||
void CollisionHandlerPhysical::
|
||||
add_collider(const NodePath &collider, const NodePath &target) {
|
||||
nassertv(!collider.is_empty() && collider.node()->is_of_type(CollisionNode::get_class_type()));
|
||||
nassertv(!target.is_empty());
|
||||
nassertv(validate_target(target));
|
||||
_colliders[collider].set_target(target);
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +135,7 @@ void CollisionHandlerPhysical::
|
|||
add_collider(const NodePath &collider, const NodePath &target,
|
||||
DriveInterface *drive_interface) {
|
||||
nassertv(!collider.is_empty() && collider.node()->is_of_type(CollisionNode::get_class_type()));
|
||||
nassertv(!target.is_empty());
|
||||
nassertv(validate_target(target));
|
||||
_colliders[collider].set_target(target, drive_interface);
|
||||
}
|
||||
|
||||
|
|
@ -177,3 +177,16 @@ void CollisionHandlerPhysical::
|
|||
clear_colliders() {
|
||||
_colliders.clear();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CollisionHandlerPhysical::validate_target
|
||||
// Access: Protected, Virtual
|
||||
// Description: Called internally to validate the target passed to
|
||||
// add_collider(). Returns true if acceptable, false
|
||||
// otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool CollisionHandlerPhysical::
|
||||
validate_target(const NodePath &target) {
|
||||
nassertr_always(!target.is_empty(), false);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ protected:
|
|||
virtual bool handle_entries()=0;
|
||||
virtual void apply_linear_force(ColliderDef &def, const LVector3f &force)=0;
|
||||
|
||||
virtual bool validate_target(const NodePath &target);
|
||||
|
||||
typedef pvector< PT(CollisionEntry) > Entries;
|
||||
typedef pmap<NodePath, Entries> FromEntries;
|
||||
FromEntries _from_entries;
|
||||
|
|
|
|||
|
|
@ -82,15 +82,6 @@ apply_friction(ColliderDef &def, LVector3f& vel, const LVector3f& force,
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysicsCollisionHandler::apply_linear_force
|
||||
// Access: Protected, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysicsCollisionHandler::
|
||||
apply_linear_force(ColliderDef &def, const LVector3f &force) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysicsCollisionHandler::apply_net_shove
|
||||
// Access: Protected, Virtual
|
||||
|
|
@ -196,3 +187,28 @@ apply_net_shove(ColliderDef &def, const LVector3f& net_shove,
|
|||
actor->set_contact_vector(adjustment);
|
||||
actor->get_physics_object()->set_velocity(vel);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysicsCollisionHandler::apply_linear_force
|
||||
// Access: Protected, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void PhysicsCollisionHandler::
|
||||
apply_linear_force(ColliderDef &def, const LVector3f &force) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PhysicsCollisionHandler::validate_target
|
||||
// Access: Protected, Virtual
|
||||
// Description: Called internally to validate the target passed to
|
||||
// add_collider(). Returns true if acceptable, false
|
||||
// otherwise.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool PhysicsCollisionHandler::
|
||||
validate_target(const NodePath &target) {
|
||||
if (!CollisionHandlerPhysical::validate_target(target)) {
|
||||
return false;
|
||||
}
|
||||
nassertr_always(target.node()->is_of_type(ActorNode::get_class_type()), false);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ protected:
|
|||
const LVector3f &force_normal);
|
||||
virtual void apply_linear_force(ColliderDef &def, const LVector3f &force);
|
||||
|
||||
virtual bool validate_target(const NodePath &target);
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
|
|
|
|||
Loading…
Reference in New Issue