diff options
Diffstat (limited to 'servers/physics_server.h')
-rw-r--r-- | servers/physics_server.h | 87 |
1 files changed, 55 insertions, 32 deletions
diff --git a/servers/physics_server.h b/servers/physics_server.h index dbd0c79f06..b38e14eb0c 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -6,6 +6,7 @@ /* http://www.godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -99,7 +100,7 @@ class PhysicsShapeQueryParameters : public Reference { Transform transform; float margin; Set<RID> exclude; - uint32_t layer_mask; + uint32_t collision_layer; uint32_t object_type_mask; protected: @@ -116,8 +117,8 @@ public: void set_margin(float p_margin); float get_margin() const; - void set_layer_mask(int p_layer_mask); - int get_layer_mask() const; + void set_collision_layer(int p_collision_layer); + int get_collision_layer() const; void set_object_type_mask(int p_object_type_mask); int get_object_type_mask() const; @@ -155,27 +156,29 @@ protected: static void _bind_methods(); public: - struct RayResult { + struct ShapeResult { - Vector3 position; - Vector3 normal; RID rid; ObjectID collider_id; Object *collider; int shape; }; - virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_layer_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, bool p_pick_ray = false) = 0; + virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION) = 0; - struct ShapeResult { + struct RayResult { + Vector3 position; + Vector3 normal; RID rid; ObjectID collider_id; Object *collider; int shape; }; - virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_layer_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION) = 0; + virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, bool p_pick_ray = false) = 0; + + virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, float p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION) = 0; struct ShapeRestInfo { @@ -187,11 +190,13 @@ public: Vector3 linear_velocity; //velocity at contact point }; - virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &p_closest_safe, float &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_layer_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, ShapeRestInfo *r_info = NULL) = 0; + virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &p_closest_safe, float &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, ShapeRestInfo *r_info = NULL) = 0; + + virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION) = 0; - virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, float p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_layer_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION) = 0; + virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION) = 0; - virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, float p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_layer_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION) = 0; + virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const = 0; PhysicsDirectSpaceState(); }; @@ -260,8 +265,8 @@ public: SPACE_PARAM_CONTACT_RECYCLE_RADIUS, SPACE_PARAM_CONTACT_MAX_SEPARATION, SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION, - SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD, - SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_TRESHOLD, + SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_THRESHOLD, + SPACE_PARAM_BODY_ANGULAR_VELOCITY_SLEEP_THRESHOLD, SPACE_PARAM_BODY_TIME_TO_SLEEP, SPACE_PARAM_BODY_ANGULAR_VELOCITY_DAMP_RATIO, SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS, @@ -321,8 +326,10 @@ public: virtual void area_remove_shape(RID p_area, int p_shape_idx) = 0; virtual void area_clear_shapes(RID p_area) = 0; - virtual void area_attach_object_instance_ID(RID p_area, ObjectID p_ID) = 0; - virtual ObjectID area_get_object_instance_ID(RID p_area) const = 0; + virtual void area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) = 0; + + virtual void area_attach_object_instance_id(RID p_area, ObjectID p_ID) = 0; + virtual ObjectID area_get_object_instance_id(RID p_area) const = 0; virtual void area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) = 0; virtual void area_set_transform(RID p_area, const Transform &p_transform) = 0; @@ -331,7 +338,7 @@ public: virtual Transform area_get_transform(RID p_area) const = 0; virtual void area_set_collision_mask(RID p_area, uint32_t p_mask) = 0; - virtual void area_set_layer_mask(RID p_area, uint32_t p_mask) = 0; + virtual void area_set_collision_layer(RID p_area, uint32_t p_layer) = 0; virtual void area_set_monitorable(RID p_area, bool p_monitorable) = 0; @@ -369,26 +376,25 @@ public: virtual RID body_get_shape(RID p_body, int p_shape_idx) const = 0; virtual Transform body_get_shape_transform(RID p_body, int p_shape_idx) const = 0; - virtual void body_set_shape_as_trigger(RID p_body, int p_shape_idx, bool p_enable) = 0; - virtual bool body_is_shape_set_as_trigger(RID p_body, int p_shape_idx) const = 0; - virtual void body_remove_shape(RID p_body, int p_shape_idx) = 0; virtual void body_clear_shapes(RID p_body) = 0; - virtual void body_attach_object_instance_ID(RID p_body, uint32_t p_ID) = 0; - virtual uint32_t body_get_object_instance_ID(RID p_body) const = 0; + virtual void body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) = 0; + + virtual void body_attach_object_instance_id(RID p_body, uint32_t p_ID) = 0; + virtual uint32_t body_get_object_instance_id(RID p_body) const = 0; virtual void body_set_enable_continuous_collision_detection(RID p_body, bool p_enable) = 0; virtual bool body_is_continuous_collision_detection_enabled(RID p_body) const = 0; - virtual void body_set_layer_mask(RID p_body, uint32_t p_mask) = 0; - virtual uint32_t body_get_layer_mask(RID p_body, uint32_t p_mask) const = 0; + virtual void body_set_collision_layer(RID p_body, uint32_t p_layer) = 0; + virtual uint32_t body_get_collision_layer(RID p_body) const = 0; virtual void body_set_collision_mask(RID p_body, uint32_t p_mask) = 0; - virtual uint32_t body_get_collision_mask(RID p_body, uint32_t p_mask) const = 0; + virtual uint32_t body_get_collision_mask(RID p_body) const = 0; virtual void body_set_user_flags(RID p_body, uint32_t p_flags) = 0; - virtual uint32_t body_get_user_flags(RID p_body, uint32_t p_flags) const = 0; + virtual uint32_t body_get_user_flags(RID p_body) const = 0; // common body variables enum BodyParameter { @@ -446,8 +452,8 @@ public: virtual int body_get_max_contacts_reported(RID p_body) const = 0; //missing remove - virtual void body_set_contacts_reported_depth_treshold(RID p_body, float p_treshold) = 0; - virtual float body_get_contacts_reported_depth_treshold(RID p_body) const = 0; + virtual void body_set_contacts_reported_depth_threshold(RID p_body, float p_threshold) = 0; + virtual float body_get_contacts_reported_depth_threshold(RID p_body) const = 0; virtual void body_set_omit_force_integration(RID p_body, bool p_omit) = 0; virtual bool body_is_omitting_force_integration(RID p_body) const = 0; @@ -457,6 +463,23 @@ public: virtual void body_set_ray_pickable(RID p_body, bool p_enable) = 0; virtual bool body_is_ray_pickable(RID p_body) const = 0; + struct MotionResult { + + Vector3 motion; + Vector3 remainder; + + Vector3 collision_point; + Vector3 collision_normal; + Vector3 collider_velocity; + int collision_local_shape; + ObjectID collider_id; + RID collider; + int collider_shape; + Variant collider_metadata; + }; + + virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, float p_margin = 0.001, MotionResult *r_result = NULL) = 0; + /* JOINT API */ enum JointType { @@ -485,11 +508,11 @@ public: virtual void pin_joint_set_param(RID p_joint, PinJointParam p_param, float p_value) = 0; virtual float pin_joint_get_param(RID p_joint, PinJointParam p_param) const = 0; - virtual void pin_joint_set_local_A(RID p_joint, const Vector3 &p_A) = 0; - virtual Vector3 pin_joint_get_local_A(RID p_joint) const = 0; + virtual void pin_joint_set_local_a(RID p_joint, const Vector3 &p_A) = 0; + virtual Vector3 pin_joint_get_local_a(RID p_joint) const = 0; - virtual void pin_joint_set_local_B(RID p_joint, const Vector3 &p_B) = 0; - virtual Vector3 pin_joint_get_local_B(RID p_joint) const = 0; + virtual void pin_joint_set_local_b(RID p_joint, const Vector3 &p_B) = 0; + virtual Vector3 pin_joint_get_local_b(RID p_joint) const = 0; enum HingeJointParam { |