2016-06-18 14:46:12 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* collision_polygon.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2017-01-01 22:01:57 +01:00
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 00:11:42 +02:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2016-06-18 14:46:12 +02:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2014-09-17 02:19:54 +02:00
|
|
|
#ifndef COLLISION_POLYGON_H
|
|
|
|
#define COLLISION_POLYGON_H
|
|
|
|
|
|
|
|
#include "scene/3d/spatial.h"
|
|
|
|
#include "scene/resources/shape.h"
|
|
|
|
|
|
|
|
class CollisionPolygon : public Spatial {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(CollisionPolygon, Spatial);
|
2014-09-17 02:19:54 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2014-09-17 02:19:54 +02:00
|
|
|
enum BuildMode {
|
|
|
|
BUILD_SOLIDS,
|
|
|
|
BUILD_TRIANGLES,
|
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
float depth;
|
2017-01-11 04:52:51 +01:00
|
|
|
Rect3 aabb;
|
2014-09-17 02:19:54 +02:00
|
|
|
BuildMode build_mode;
|
|
|
|
Vector<Point2> polygon;
|
|
|
|
|
|
|
|
void _add_to_collision_object(Object *p_obj);
|
|
|
|
void _update_parent();
|
|
|
|
|
2015-09-16 03:07:03 +02:00
|
|
|
bool can_update_body;
|
|
|
|
int shape_from;
|
|
|
|
int shape_to;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void _set_shape_range(const Vector2 &p_range);
|
2015-09-16 03:07:03 +02:00
|
|
|
Vector2 _get_shape_range() const;
|
|
|
|
|
2014-09-17 02:19:54 +02:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2014-09-17 02:19:54 +02:00
|
|
|
void set_build_mode(BuildMode p_mode);
|
|
|
|
BuildMode get_build_mode() const;
|
|
|
|
|
|
|
|
void set_depth(float p_depth);
|
|
|
|
float get_depth() const;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_polygon(const Vector<Point2> &p_polygon);
|
2014-09-17 02:19:54 +02:00
|
|
|
Vector<Point2> get_polygon() const;
|
|
|
|
|
2017-01-11 04:52:51 +01:00
|
|
|
virtual Rect3 get_item_rect() const;
|
2015-09-16 03:07:03 +02:00
|
|
|
|
|
|
|
int get_collision_object_first_shape() const { return shape_from; }
|
|
|
|
int get_collision_object_last_shape() const { return shape_to; }
|
|
|
|
|
2016-05-17 23:27:15 +02:00
|
|
|
String get_configuration_warning() const;
|
|
|
|
|
2014-09-17 02:19:54 +02:00
|
|
|
CollisionPolygon();
|
|
|
|
};
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
VARIANT_ENUM_CAST(CollisionPolygon::BuildMode);
|
2014-09-17 02:19:54 +02:00
|
|
|
#endif // COLLISION_POLYGON_H
|