Clean up CollisionBox interface a bit; add properties to collide classes
This commit is contained in:
parent
aa3f3ab51b
commit
9e38ba9f9c
|
|
@ -644,7 +644,7 @@ add_shapes_from_collision_solids(CollisionNode *cnode) {
|
|||
// CollisionBox
|
||||
else if (CollisionBox::get_class_type() == type) {
|
||||
CPT(CollisionBox) box = DCAST(CollisionBox, solid);
|
||||
CPT(TransformState) ts = TransformState::make_pos(box->get_approx_center());
|
||||
CPT(TransformState) ts = TransformState::make_pos(box->get_center());
|
||||
|
||||
add_shape(BulletBoxShape::make_from_solid(box), ts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,6 +130,26 @@ get_center() const {
|
|||
return _center;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CollisionBox::get_min
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const LPoint3 &CollisionBox::
|
||||
get_min() const {
|
||||
return _min;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CollisionBox::get_max
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const LPoint3 &CollisionBox::
|
||||
get_max() const {
|
||||
return _max;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CollisionBox::get_dimensions
|
||||
// Access: Published
|
||||
|
|
@ -140,22 +160,12 @@ get_dimensions() const {
|
|||
return _max - _min;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CollisionBox::get_radius
|
||||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE PN_stdfloat CollisionBox::
|
||||
get_radius() const {
|
||||
return _radius;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CollisionBox::get_num_points
|
||||
// Access: Published
|
||||
// Description: Returns 8: the number of vertices of a rectangular solid.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_MATHUTIL int CollisionBox::
|
||||
INLINE int CollisionBox::
|
||||
get_num_points() const {
|
||||
return 8;
|
||||
}
|
||||
|
|
@ -165,7 +175,7 @@ get_num_points() const {
|
|||
// Access: Published
|
||||
// Description: Returns the nth vertex of the OBB.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_MATHUTIL LPoint3 CollisionBox::
|
||||
INLINE LPoint3 CollisionBox::
|
||||
get_point(int n) const {
|
||||
nassertr(n >= 0 && n < 8, LPoint3::zero());
|
||||
return _vertex[n];
|
||||
|
|
@ -177,7 +187,7 @@ get_point(int n) const {
|
|||
// Access: Published
|
||||
// Description: Returns the nth vertex of the Axis Aligned Bounding Box.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_MATHUTIL LPoint3 CollisionBox::
|
||||
INLINE LPoint3 CollisionBox::
|
||||
get_point_aabb(int n) const {
|
||||
nassertr(n >= 0 && n < 8, LPoint3::zero());
|
||||
|
||||
|
|
@ -192,7 +202,7 @@ get_point_aabb(int n) const {
|
|||
// Access: Published
|
||||
// Description: Returns 6: the number of faces of a rectangular solid.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_MATHUTIL int CollisionBox::
|
||||
INLINE int CollisionBox::
|
||||
get_num_planes() const {
|
||||
return 6;
|
||||
}
|
||||
|
|
@ -202,7 +212,7 @@ get_num_planes() const {
|
|||
// Access: Published
|
||||
// Description: Returns the nth face of the rectangular solid.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_MATHUTIL LPlane CollisionBox::
|
||||
INLINE LPlane CollisionBox::
|
||||
get_plane(int n) const {
|
||||
nassertr(n >= 0 && n < 6, LPlane());
|
||||
return _planes[n];
|
||||
|
|
@ -213,7 +223,7 @@ get_plane(int n) const {
|
|||
// Access: Published
|
||||
// Description: Creates the nth face of the rectangular solid.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE_MATHUTIL LPlane CollisionBox::
|
||||
INLINE LPlane CollisionBox::
|
||||
set_plane(int n) const {
|
||||
nassertr(n >= 0 && n < 6, LPlane());
|
||||
return LPlane(get_point(plane_def[n][0]),
|
||||
|
|
|
|||
|
|
@ -175,36 +175,6 @@ get_collision_origin() const {
|
|||
return _center;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CollisionBox::get_min
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
LPoint3 CollisionBox::
|
||||
get_min() const {
|
||||
return _min;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CollisionBox::get_max
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
LPoint3 CollisionBox::
|
||||
get_max() const {
|
||||
return _max;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CollisionBox::get_approx_center
|
||||
// Access: Public, Virtual
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
LPoint3 CollisionBox::
|
||||
get_approx_center() const {
|
||||
return (_min + _max) * 0.5f;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: CollisionBox::get_volume_pcollector
|
||||
// Access: Public, Virtual
|
||||
|
|
|
|||
|
|
@ -50,26 +50,29 @@ public:
|
|||
virtual PStatCollector &get_test_pcollector();
|
||||
|
||||
virtual void output(ostream &out) const;
|
||||
|
||||
virtual LPoint3 get_approx_center() const;
|
||||
virtual LPoint3 get_min() const;
|
||||
virtual LPoint3 get_max() const;
|
||||
|
||||
INLINE static void flush_level();
|
||||
void setup_box();
|
||||
|
||||
PUBLISHED:
|
||||
INLINE_MATHUTIL int get_num_points() const;
|
||||
INLINE_MATHUTIL LPoint3 get_point_aabb(int n) const;
|
||||
INLINE_MATHUTIL LPoint3 get_point(int n) const;
|
||||
INLINE_MATHUTIL int get_num_planes() const;
|
||||
INLINE_MATHUTIL LPlane set_plane(int n) const;
|
||||
INLINE_MATHUTIL LPlane get_plane(int n) const;
|
||||
INLINE int get_num_points() const;
|
||||
INLINE LPoint3 get_point_aabb(int n) const;
|
||||
INLINE LPoint3 get_point(int n) const;
|
||||
INLINE int get_num_planes() const;
|
||||
INLINE LPlane set_plane(int n) const;
|
||||
INLINE LPlane get_plane(int n) const;
|
||||
INLINE void set_center(const LPoint3 ¢er);
|
||||
INLINE void set_center(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
|
||||
INLINE const LPoint3 &get_center() const;
|
||||
INLINE const LPoint3 &get_min() const;
|
||||
INLINE const LPoint3 &get_max() const;
|
||||
INLINE LVector3 get_dimensions() const;
|
||||
INLINE PN_stdfloat get_radius() const;
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(center, get_center);
|
||||
MAKE_PROPERTY(min, get_min);
|
||||
MAKE_PROPERTY(max, get_max);
|
||||
MAKE_PROPERTY(dimensions, get_dimensions);
|
||||
|
||||
protected:
|
||||
virtual PT(BoundingVolume) compute_internal_bounds() const;
|
||||
|
|
|
|||
|
|
@ -97,6 +97,17 @@ PUBLISHED:
|
|||
void output(ostream &out) const;
|
||||
void write(ostream &out, int indent_level = 0) const;
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(from, get_from);
|
||||
MAKE_PROPERTY(into, get_into);
|
||||
MAKE_PROPERTY(from_node, get_from_node);
|
||||
MAKE_PROPERTY(into_node, get_into_node);
|
||||
MAKE_PROPERTY(from_node_path, get_from_node_path);
|
||||
MAKE_PROPERTY(into_node_path, get_into_node_path);
|
||||
|
||||
MAKE_PROPERTY(t, get_t, set_t);
|
||||
MAKE_PROPERTY(respect_prev_transform, get_respect_prev_transform);
|
||||
|
||||
public:
|
||||
INLINE CPT(TransformState) get_wrt_space() const;
|
||||
INLINE CPT(TransformState) get_inv_wrt_space() const;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ PUBLISHED:
|
|||
INLINE void set_max_velocity(PN_stdfloat max_vel);
|
||||
INLINE PN_stdfloat get_max_velocity() const;
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(offset, get_offset, set_offset);
|
||||
MAKE_PROPERTY(reach, get_reach, set_reach);
|
||||
MAKE_PROPERTY(max_velocity, get_max_velocity, set_max_velocity);
|
||||
|
||||
protected:
|
||||
PN_stdfloat set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries);
|
||||
virtual bool handle_entries();
|
||||
|
|
|
|||
|
|
@ -57,6 +57,17 @@ PUBLISHED:
|
|||
INLINE void set_legacy_mode(bool legacy_mode);
|
||||
INLINE bool get_legacy_mode() const;
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(offset, get_offset, set_offset);
|
||||
MAKE_PROPERTY(reach, get_reach, set_reach);
|
||||
MAKE_PROPERTY(airborne_height, get_airborne_height);
|
||||
MAKE_PROPERTY(on_ground, is_on_ground);
|
||||
MAKE_PROPERTY(impact_velocity, get_impact_velocity);
|
||||
MAKE_PROPERTY(contact_normal, get_contact_normal);
|
||||
MAKE_PROPERTY(velocity, get_velocity, set_velocity);
|
||||
MAKE_PROPERTY(gravity, get_gravity, set_gravity);
|
||||
MAKE_PROPERTY(max_velocity, get_max_velocity, set_max_velocity);
|
||||
|
||||
protected:
|
||||
PN_stdfloat set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries);
|
||||
virtual bool handle_entries();
|
||||
|
|
|
|||
|
|
@ -54,6 +54,9 @@ PUBLISHED:
|
|||
INLINE bool has_center() const;
|
||||
INLINE bool has_contact() const;
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY2(center, has_center, get_center, set_center, clear_center);
|
||||
|
||||
protected:
|
||||
bool _has_contact; // Are we in contact with anything?
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ PUBLISHED:
|
|||
INLINE void set_horizontal(bool flag);
|
||||
INLINE bool get_horizontal() const;
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(horizontal, get_horizontal, set_horizontal);
|
||||
|
||||
protected:
|
||||
virtual bool handle_entries();
|
||||
virtual void apply_net_shove(
|
||||
|
|
|
|||
|
|
@ -63,6 +63,11 @@ PUBLISHED:
|
|||
INLINE void set_t2(PN_stdfloat t2);
|
||||
INLINE PN_stdfloat get_t2() const;
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(parabola, get_parabola, set_parabola);
|
||||
MAKE_PROPERTY(t1, get_t1, set_t1);
|
||||
MAKE_PROPERTY(t2, get_t2, set_t2);
|
||||
|
||||
protected:
|
||||
virtual PT(BoundingVolume) compute_internal_bounds() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ PUBLISHED:
|
|||
|
||||
INLINE void flip();
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(normal, get_normal);
|
||||
MAKE_PROPERTY(plane, get_plane, set_plane);
|
||||
|
||||
protected:
|
||||
virtual PT(BoundingVolume) compute_internal_bounds() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,10 @@ PUBLISHED:
|
|||
bool is_valid() const;
|
||||
bool is_concave() const;
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(valid, is_valid);
|
||||
MAKE_PROPERTY(concave, is_concave);
|
||||
|
||||
public:
|
||||
virtual void xform(const LMatrix4 &mat);
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@ PUBLISHED:
|
|||
bool set_from_lens(LensNode *camera, const LPoint2 &point);
|
||||
INLINE bool set_from_lens(LensNode *camera, PN_stdfloat px, PN_stdfloat py);
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(point_a, get_point_a, set_point_a);
|
||||
MAKE_PROPERTY(point_b, get_point_b, set_point_b);
|
||||
|
||||
protected:
|
||||
virtual PT(BoundingVolume) compute_internal_bounds() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,10 @@ PUBLISHED:
|
|||
INLINE void set_radius(PN_stdfloat radius);
|
||||
INLINE PN_stdfloat get_radius() const;
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(center, get_center, set_center);
|
||||
MAKE_PROPERTY(radius, get_radius, set_radius);
|
||||
|
||||
protected:
|
||||
virtual PT(BoundingVolume) compute_internal_bounds() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ PUBLISHED:
|
|||
|
||||
INLINE void set_respect_prev_transform(bool flag);
|
||||
INLINE bool get_respect_prev_transform() const;
|
||||
MAKE_PROPERTY(respect_preV_transform, get_respect_prev_transform,
|
||||
set_respect_prev_transform);
|
||||
|
||||
void add_collider(const NodePath &collider, CollisionHandler *handler);
|
||||
bool remove_collider(const NodePath &collider);
|
||||
|
|
@ -70,6 +72,8 @@ PUBLISHED:
|
|||
INLINE bool has_recorder() const;
|
||||
INLINE CollisionRecorder *get_recorder() const;
|
||||
INLINE void clear_recorder();
|
||||
MAKE_PROPERTY2(recorder, has_recorder, get_recorder,
|
||||
set_recorder, clear_recorder);
|
||||
|
||||
CollisionVisualizer *show_collisions(const NodePath &root);
|
||||
void hide_collisions();
|
||||
|
|
|
|||
|
|
@ -65,6 +65,11 @@ PUBLISHED:
|
|||
INLINE void set_radius(PN_stdfloat radius);
|
||||
INLINE PN_stdfloat get_radius() const;
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(point_a, get_point_a, set_point_a);
|
||||
MAKE_PROPERTY(point_b, get_point_b, set_point_b);
|
||||
MAKE_PROPERTY(radius, get_radius, set_radius);
|
||||
|
||||
protected:
|
||||
virtual PT(BoundingVolume) compute_internal_bounds() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ PUBLISHED:
|
|||
|
||||
void clear();
|
||||
|
||||
PUBLISHED:
|
||||
MAKE_PROPERTY(point_scale, get_point_scale, set_point_scale);
|
||||
MAKE_PROPERTY(normal_scale, get_normal_scale, set_normal_scale);
|
||||
|
||||
public:
|
||||
// from parent class PandaNode.
|
||||
virtual PandaNode *make_copy() const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue