collision_polygon.h
1 #ifndef COLLISION_POLYGON_H
2 #define COLLISION_POLYGON_H
3 
4 #include "scene/3d/spatial.h"
5 #include "scene/resources/shape.h"
6 
7 
8 
9 class CollisionPolygon : public Spatial {
10 
11  OBJ_TYPE(CollisionPolygon,Spatial);
12 public:
13 
14  enum BuildMode {
15  BUILD_SOLIDS,
16  BUILD_TRIANGLES,
17  };
18 
19 protected:
20 
21 
22  float depth;
23  AABB aabb;
24  BuildMode build_mode;
25  Vector<Point2> polygon;
26 
27 
28  void _add_to_collision_object(Object *p_obj);
29  void _update_parent();
30 
31  bool can_update_body;
32  int shape_from;
33  int shape_to;
34 
35  void _set_shape_range(const Vector2& p_range);
36  Vector2 _get_shape_range() const;
37 
38 protected:
39 
40  void _notification(int p_what);
41  static void _bind_methods();
42 public:
43 
44  void set_build_mode(BuildMode p_mode);
45  BuildMode get_build_mode() const;
46 
47  void set_depth(float p_depth);
48  float get_depth() const;
49 
50  void set_polygon(const Vector<Point2>& p_polygon);
51  Vector<Point2> get_polygon() const;
52 
53  virtual AABB get_item_rect() const;
54 
55  int get_collision_object_first_shape() const { return shape_from; }
56  int get_collision_object_last_shape() const { return shape_to; }
57 
59 };
60 
61 VARIANT_ENUM_CAST( CollisionPolygon::BuildMode );
62 #endif // COLLISION_POLYGON_H
Definition: aabb.h:43
Definition: math_2d.h:65
Definition: collision_polygon.h:9
Definition: vector.h:43
Definition: object.h:317
Definition: spatial.h:56