collision_polygon.h 1.1 KB

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