summaryrefslogtreecommitdiff
path: root/servers/physics/collision_object_sw.h
diff options
context:
space:
mode:
Diffstat (limited to 'servers/physics/collision_object_sw.h')
-rw-r--r--servers/physics/collision_object_sw.h66
1 files changed, 31 insertions, 35 deletions
diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h
index c46a7f4a5f..9a7626d583 100644
--- a/servers/physics/collision_object_sw.h
+++ b/servers/physics/collision_object_sw.h
@@ -29,14 +29,14 @@
#ifndef COLLISION_OBJECT_SW_H
#define COLLISION_OBJECT_SW_H
-#include "shape_sw.h"
-#include "servers/physics_server.h"
-#include "self_list.h"
#include "broad_phase_sw.h"
+#include "self_list.h"
+#include "servers/physics_server.h"
+#include "shape_sw.h"
#ifdef DEBUG_ENABLED
#define MAX_OBJECT_DISTANCE 10000000.0
-#define MAX_OBJECT_DISTANCE_X2 (MAX_OBJECT_DISTANCE*MAX_OBJECT_DISTANCE)
+#define MAX_OBJECT_DISTANCE_X2 (MAX_OBJECT_DISTANCE * MAX_OBJECT_DISTANCE)
#endif
class SpaceSW;
@@ -47,8 +47,8 @@ public:
TYPE_AREA,
TYPE_BODY
};
-private:
+private:
Type type;
RID self;
ObjectID instance_id;
@@ -65,7 +65,7 @@ private:
ShapeSW *shape;
bool trigger;
- Shape() { trigger=false; }
+ Shape() { trigger = false; }
};
Vector<Shape> shapes;
@@ -77,84 +77,80 @@ private:
void _update_shapes();
protected:
-
-
- void _update_shapes_with_motion(const Vector3& p_motion);
+ void _update_shapes_with_motion(const Vector3 &p_motion);
void _unregister_shapes();
- _FORCE_INLINE_ void _set_transform(const Transform& p_transform,bool p_update_shapes=true) {
+ _FORCE_INLINE_ void _set_transform(const Transform &p_transform, bool p_update_shapes = true) {
#ifdef DEBUG_ENABLED
if (p_transform.origin.length_squared() > MAX_OBJECT_DISTANCE_X2) {
- ERR_EXPLAIN("Object went too far away (more than "+itos(MAX_OBJECT_DISTANCE)+"mts from origin).");
+ ERR_EXPLAIN("Object went too far away (more than " + itos(MAX_OBJECT_DISTANCE) + "mts from origin).");
ERR_FAIL();
}
#endif
- transform=p_transform; if (p_update_shapes) _update_shapes();
-
+ transform = p_transform;
+ if (p_update_shapes) _update_shapes();
}
- _FORCE_INLINE_ void _set_inv_transform(const Transform& p_transform) { inv_transform=p_transform; }
+ _FORCE_INLINE_ void _set_inv_transform(const Transform &p_transform) { inv_transform = p_transform; }
void _set_static(bool p_static);
- virtual void _shapes_changed()=0;
+ virtual void _shapes_changed() = 0;
void _set_space(SpaceSW *space);
bool ray_pickable;
-
CollisionObjectSW(Type p_type);
-public:
- _FORCE_INLINE_ void set_self(const RID& p_self) { self=p_self; }
+public:
+ _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
_FORCE_INLINE_ RID get_self() const { return self; }
- _FORCE_INLINE_ void set_instance_id(const ObjectID& p_instance_id) { instance_id=p_instance_id; }
+ _FORCE_INLINE_ void set_instance_id(const ObjectID &p_instance_id) { instance_id = p_instance_id; }
_FORCE_INLINE_ ObjectID get_instance_id() const { return instance_id; }
void _shape_changed();
_FORCE_INLINE_ Type get_type() const { return type; }
- void add_shape(ShapeSW *p_shape,const Transform& p_transform=Transform());
- void set_shape(int p_index,ShapeSW *p_shape);
- void set_shape_transform(int p_index,const Transform& p_transform);
+ void add_shape(ShapeSW *p_shape, const Transform &p_transform = Transform());
+ void set_shape(int p_index, ShapeSW *p_shape);
+ void set_shape_transform(int p_index, const Transform &p_transform);
_FORCE_INLINE_ int get_shape_count() const { return shapes.size(); }
_FORCE_INLINE_ ShapeSW *get_shape(int p_index) const { return shapes[p_index].shape; }
- _FORCE_INLINE_ const Transform& get_shape_transform(int p_index) const { return shapes[p_index].xform; }
- _FORCE_INLINE_ const Transform& get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; }
- _FORCE_INLINE_ const Rect3& get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; }
+ _FORCE_INLINE_ const Transform &get_shape_transform(int p_index) const { return shapes[p_index].xform; }
+ _FORCE_INLINE_ const Transform &get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; }
+ _FORCE_INLINE_ const Rect3 &get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; }
_FORCE_INLINE_ const real_t get_shape_area(int p_index) const { return shapes[p_index].area_cache; }
_FORCE_INLINE_ Transform get_transform() const { return transform; }
_FORCE_INLINE_ Transform get_inv_transform() const { return inv_transform; }
- _FORCE_INLINE_ SpaceSW* get_space() const { return space; }
+ _FORCE_INLINE_ SpaceSW *get_space() const { return space; }
- _FORCE_INLINE_ void set_ray_pickable(bool p_enable) { ray_pickable=p_enable; }
+ _FORCE_INLINE_ void set_ray_pickable(bool p_enable) { ray_pickable = p_enable; }
_FORCE_INLINE_ bool is_ray_pickable() const { return ray_pickable; }
- _FORCE_INLINE_ void set_shape_as_trigger(int p_idx,bool p_enable) { shapes[p_idx].trigger=p_enable; }
+ _FORCE_INLINE_ void set_shape_as_trigger(int p_idx, bool p_enable) { shapes[p_idx].trigger = p_enable; }
_FORCE_INLINE_ bool is_shape_set_as_trigger(int p_idx) const { return shapes[p_idx].trigger; }
- _FORCE_INLINE_ void set_layer_mask(uint32_t p_mask) { layer_mask=p_mask; }
+ _FORCE_INLINE_ void set_layer_mask(uint32_t p_mask) { layer_mask = p_mask; }
_FORCE_INLINE_ uint32_t get_layer_mask() const { return layer_mask; }
- _FORCE_INLINE_ void set_collision_mask(uint32_t p_mask) { collision_mask=p_mask; }
+ _FORCE_INLINE_ void set_collision_mask(uint32_t p_mask) { collision_mask = p_mask; }
_FORCE_INLINE_ uint32_t get_collision_mask() const { return collision_mask; }
- _FORCE_INLINE_ bool test_collision_mask(CollisionObjectSW* p_other) const {
- return layer_mask&p_other->collision_mask || p_other->layer_mask&collision_mask;
+ _FORCE_INLINE_ bool test_collision_mask(CollisionObjectSW *p_other) const {
+ return layer_mask & p_other->collision_mask || p_other->layer_mask & collision_mask;
}
void remove_shape(ShapeSW *p_shape);
void remove_shape(int p_index);
- virtual void set_space(SpaceSW *p_space)=0;
+ virtual void set_space(SpaceSW *p_space) = 0;
- _FORCE_INLINE_ bool is_static() const { return _static; }
+ _FORCE_INLINE_ bool is_static() const { return _static; }
virtual ~CollisionObjectSW() {}
-
};
#endif // COLLISION_OBJECT_SW_H