2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* physics_2d_server_wrap_mt.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
2022-01-13 08:45:09 +00:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2016-06-18 12:46:12 +00: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. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2022-07-25 10:33:41 +00:00
|
|
|
#ifndef PHYSICS_2D_SERVER_WRAP_MT_H
|
|
|
|
#define PHYSICS_2D_SERVER_WRAP_MT_H
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2018-09-11 16:13:45 +00:00
|
|
|
#include "core/command_queue_mt.h"
|
|
|
|
#include "core/os/thread.h"
|
|
|
|
#include "core/project_settings.h"
|
2021-01-31 12:34:42 +00:00
|
|
|
#include "core/safe_refcount.h"
|
2017-03-05 15:44:50 +00:00
|
|
|
#include "servers/physics_2d_server.h"
|
2015-05-26 04:05:08 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_SYNC
|
2017-03-05 15:44:50 +00:00
|
|
|
#define SYNC_DEBUG print_line("sync on: " + String(__FUNCTION__));
|
2015-05-26 04:05:08 +00:00
|
|
|
#else
|
|
|
|
#define SYNC_DEBUG
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class Physics2DServerWrapMT : public Physics2DServer {
|
|
|
|
mutable Physics2DServer *physics_2d_server;
|
|
|
|
|
|
|
|
mutable CommandQueueMT command_queue;
|
|
|
|
|
|
|
|
static void _thread_callback(void *_instance);
|
|
|
|
void thread_loop();
|
|
|
|
|
|
|
|
Thread::ID server_thread;
|
2015-05-26 04:30:36 +00:00
|
|
|
Thread::ID main_thread;
|
2021-01-31 12:34:42 +00:00
|
|
|
SafeFlag exit;
|
2021-01-27 19:10:10 +00:00
|
|
|
Thread thread;
|
2021-01-31 12:34:42 +00:00
|
|
|
SafeFlag step_thread_up;
|
2015-05-26 04:05:08 +00:00
|
|
|
bool create_thread;
|
|
|
|
|
2021-01-27 12:41:10 +00:00
|
|
|
Semaphore step_sem;
|
2017-02-13 23:25:05 +00:00
|
|
|
void thread_step(real_t p_delta);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
|
|
|
void thread_exit();
|
|
|
|
|
2015-05-26 04:30:36 +00:00
|
|
|
bool first_frame;
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2021-01-27 09:43:02 +00:00
|
|
|
Mutex alloc_mutex;
|
2017-11-10 02:34:01 +00:00
|
|
|
int pool_max_size;
|
2015-05-26 04:05:08 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
#define ServerName Physics2DServer
|
|
|
|
#define ServerNameWrapMT Physics2DServerWrapMT
|
|
|
|
#define server_name physics_2d_server
|
|
|
|
#include "servers/server_wrap_mt_common.h"
|
|
|
|
|
|
|
|
//FUNC1RID(shape,ShapeType); todo fix
|
2017-11-10 02:34:01 +00:00
|
|
|
FUNCRID(line_shape)
|
|
|
|
FUNCRID(ray_shape)
|
|
|
|
FUNCRID(segment_shape)
|
|
|
|
FUNCRID(circle_shape)
|
|
|
|
FUNCRID(rectangle_shape)
|
|
|
|
FUNCRID(capsule_shape)
|
|
|
|
FUNCRID(convex_polygon_shape)
|
|
|
|
FUNCRID(concave_polygon_shape)
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(shape_set_data, RID, const Variant &);
|
|
|
|
FUNC2(shape_set_custom_solver_bias, RID, real_t);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC1RC(ShapeType, shape_get_type, RID);
|
|
|
|
FUNC1RC(Variant, shape_get_data, RID);
|
|
|
|
FUNC1RC(real_t, shape_get_custom_solver_bias, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
|
|
|
//these work well, but should be used from the main thread only
|
2017-03-05 15:44:50 +00:00
|
|
|
bool shape_collide(RID p_shape_A, const Transform2D &p_xform_A, const Vector2 &p_motion_A, RID p_shape_B, const Transform2D &p_xform_B, const Vector2 &p_motion_B, Vector2 *r_results, int p_result_max, int &r_result_count) {
|
2017-08-07 10:17:31 +00:00
|
|
|
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), false);
|
2017-03-05 15:44:50 +00:00
|
|
|
return physics_2d_server->shape_collide(p_shape_A, p_xform_A, p_motion_A, p_shape_B, p_xform_B, p_motion_B, r_results, p_result_max, r_result_count);
|
2015-05-26 04:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SPACE API */
|
|
|
|
|
2017-11-10 02:34:01 +00:00
|
|
|
FUNCRID(space);
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(space_set_active, RID, bool);
|
|
|
|
FUNC1RC(bool, space_is_active, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3(space_set_param, RID, SpaceParameter, real_t);
|
|
|
|
FUNC2RC(real_t, space_get_param, RID, SpaceParameter);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-09-29 15:33:30 +00:00
|
|
|
// this function only works on physics process, errors and returns null otherwise
|
2017-03-05 15:44:50 +00:00
|
|
|
Physics2DDirectSpaceState *space_get_direct_state(RID p_space) {
|
2021-05-04 14:00:45 +00:00
|
|
|
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), nullptr);
|
2015-05-26 04:05:08 +00:00
|
|
|
return physics_2d_server->space_get_direct_state(p_space);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(space_set_debug_contacts, RID, int);
|
2015-09-20 16:03:46 +00:00
|
|
|
virtual Vector<Vector2> space_get_contacts(RID p_space) const {
|
2017-08-07 10:17:31 +00:00
|
|
|
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), Vector<Vector2>());
|
2015-09-20 16:03:46 +00:00
|
|
|
return physics_2d_server->space_get_contacts(p_space);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int space_get_contact_count(RID p_space) const {
|
2017-08-07 10:17:31 +00:00
|
|
|
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), 0);
|
2015-09-20 16:03:46 +00:00
|
|
|
return physics_2d_server->space_get_contact_count(p_space);
|
|
|
|
}
|
|
|
|
|
2015-05-26 04:05:08 +00:00
|
|
|
/* AREA API */
|
|
|
|
|
|
|
|
//FUNC0RID(area);
|
2017-11-10 02:34:01 +00:00
|
|
|
FUNCRID(area);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(area_set_space, RID, RID);
|
|
|
|
FUNC1RC(RID, area_get_space, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(area_set_space_override_mode, RID, AreaSpaceOverrideMode);
|
|
|
|
FUNC1RC(AreaSpaceOverrideMode, area_get_space_override_mode, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2019-03-24 09:38:31 +00:00
|
|
|
FUNC4(area_add_shape, RID, RID, const Transform2D &, bool);
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3(area_set_shape, RID, int, RID);
|
|
|
|
FUNC3(area_set_shape_transform, RID, int, const Transform2D &);
|
2017-06-24 02:30:43 +00:00
|
|
|
FUNC3(area_set_shape_disabled, RID, int, bool);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC1RC(int, area_get_shape_count, RID);
|
|
|
|
FUNC2RC(RID, area_get_shape, RID, int);
|
|
|
|
FUNC2RC(Transform2D, area_get_shape_transform, RID, int);
|
|
|
|
FUNC2(area_remove_shape, RID, int);
|
|
|
|
FUNC1(area_clear_shapes, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-08-07 10:17:31 +00:00
|
|
|
FUNC2(area_attach_object_instance_id, RID, ObjectID);
|
|
|
|
FUNC1RC(ObjectID, area_get_object_instance_id, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2018-08-24 22:03:26 +00:00
|
|
|
FUNC2(area_attach_canvas_instance_id, RID, ObjectID);
|
|
|
|
FUNC1RC(ObjectID, area_get_canvas_instance_id, RID);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3(area_set_param, RID, AreaParameter, const Variant &);
|
|
|
|
FUNC2(area_set_transform, RID, const Transform2D &);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2RC(Variant, area_get_param, RID, AreaParameter);
|
|
|
|
FUNC1RC(Transform2D, area_get_transform, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(area_set_collision_mask, RID, uint32_t);
|
2017-06-13 15:45:01 +00:00
|
|
|
FUNC2(area_set_collision_layer, RID, uint32_t);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(area_set_monitorable, RID, bool);
|
|
|
|
FUNC2(area_set_pickable, RID, bool);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3(area_set_monitor_callback, RID, Object *, const StringName &);
|
|
|
|
FUNC3(area_set_area_monitor_callback, RID, Object *, const StringName &);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
|
|
|
/* BODY API */
|
|
|
|
|
|
|
|
//FUNC2RID(body,BodyMode,bool);
|
2017-11-10 02:34:01 +00:00
|
|
|
FUNCRID(body)
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(body_set_space, RID, RID);
|
|
|
|
FUNC1RC(RID, body_get_space, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(body_set_mode, RID, BodyMode);
|
|
|
|
FUNC1RC(BodyMode, body_get_mode, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2019-03-24 09:38:31 +00:00
|
|
|
FUNC4(body_add_shape, RID, RID, const Transform2D &, bool);
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3(body_set_shape, RID, int, RID);
|
|
|
|
FUNC3(body_set_shape_transform, RID, int, const Transform2D &);
|
|
|
|
FUNC3(body_set_shape_metadata, RID, int, const Variant &);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC1RC(int, body_get_shape_count, RID);
|
|
|
|
FUNC2RC(Transform2D, body_get_shape_transform, RID, int);
|
|
|
|
FUNC2RC(Variant, body_get_shape_metadata, RID, int);
|
|
|
|
FUNC2RC(RID, body_get_shape, RID, int);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-06-24 02:30:43 +00:00
|
|
|
FUNC3(body_set_shape_disabled, RID, int, bool);
|
2019-01-18 17:15:05 +00:00
|
|
|
FUNC4(body_set_shape_as_one_way_collision, RID, int, bool, float);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(body_remove_shape, RID, int);
|
|
|
|
FUNC1(body_clear_shapes, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-08-07 10:17:31 +00:00
|
|
|
FUNC2(body_attach_object_instance_id, RID, uint32_t);
|
|
|
|
FUNC1RC(uint32_t, body_get_object_instance_id, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2018-08-24 22:03:26 +00:00
|
|
|
FUNC2(body_attach_canvas_instance_id, RID, uint32_t);
|
|
|
|
FUNC1RC(uint32_t, body_get_canvas_instance_id, RID);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(body_set_continuous_collision_detection_mode, RID, CCDMode);
|
|
|
|
FUNC1RC(CCDMode, body_get_continuous_collision_detection_mode, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-06-13 15:45:01 +00:00
|
|
|
FUNC2(body_set_collision_layer, RID, uint32_t);
|
|
|
|
FUNC1RC(uint32_t, body_get_collision_layer, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(body_set_collision_mask, RID, uint32_t);
|
|
|
|
FUNC1RC(uint32_t, body_get_collision_mask, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3(body_set_param, RID, BodyParameter, real_t);
|
|
|
|
FUNC2RC(real_t, body_get_param, RID, BodyParameter);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3(body_set_state, RID, BodyState, const Variant &);
|
|
|
|
FUNC2RC(Variant, body_get_state, RID, BodyState);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(body_set_applied_force, RID, const Vector2 &);
|
|
|
|
FUNC1RC(Vector2, body_get_applied_force, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(body_set_applied_torque, RID, real_t);
|
|
|
|
FUNC1RC(real_t, body_get_applied_torque, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2018-07-24 07:49:12 +00:00
|
|
|
FUNC2(body_add_central_force, RID, const Vector2 &);
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3(body_add_force, RID, const Vector2 &, const Vector2 &);
|
2018-07-24 07:49:12 +00:00
|
|
|
FUNC2(body_add_torque, RID, real_t);
|
|
|
|
FUNC2(body_apply_central_impulse, RID, const Vector2 &);
|
|
|
|
FUNC2(body_apply_torque_impulse, RID, real_t);
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3(body_apply_impulse, RID, const Vector2 &, const Vector2 &);
|
|
|
|
FUNC2(body_set_axis_velocity, RID, const Vector2 &);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(body_add_collision_exception, RID, RID);
|
|
|
|
FUNC2(body_remove_collision_exception, RID, RID);
|
|
|
|
FUNC2S(body_get_collision_exceptions, RID, List<RID> *);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(body_set_max_contacts_reported, RID, int);
|
|
|
|
FUNC1RC(int, body_get_max_contacts_reported, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-07-08 15:12:18 +00:00
|
|
|
FUNC2(body_set_contacts_reported_depth_threshold, RID, real_t);
|
|
|
|
FUNC1RC(real_t, body_get_contacts_reported_depth_threshold, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(body_set_omit_force_integration, RID, bool);
|
|
|
|
FUNC1RC(bool, body_is_omitting_force_integration, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC4(body_set_force_integration_callback, RID, Object *, const StringName &, const Variant &);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
bool body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, Vector2 *r_results, int p_result_max, int &r_result_count) {
|
|
|
|
return physics_2d_server->body_collide_shape(p_body, p_body_shape, p_shape, p_shape_xform, p_motion, r_results, p_result_max, r_result_count);
|
2015-05-26 04:05:08 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC2(body_set_pickable, RID, bool);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2021-10-06 23:06:03 +00:00
|
|
|
FUNC8R(bool, body_test_motion, RID, const Transform2D &, const Vector2 &, bool, real_t, MotionResult *, bool, const Set<RID> &);
|
|
|
|
FUNC7R(int, body_test_ray_separation, RID, const Transform2D &, bool, Vector2 &, SeparationResult *, int, float);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-09-29 15:33:30 +00:00
|
|
|
// this function only works on physics process, errors and returns null otherwise
|
|
|
|
Physics2DDirectBodyState *body_get_direct_state(RID p_body) {
|
2021-05-04 14:00:45 +00:00
|
|
|
ERR_FAIL_COND_V(main_thread != Thread::get_caller_id(), nullptr);
|
2017-09-29 15:33:30 +00:00
|
|
|
return physics_2d_server->body_get_direct_state(p_body);
|
|
|
|
}
|
|
|
|
|
2015-05-26 04:05:08 +00:00
|
|
|
/* JOINT API */
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3(joint_set_param, RID, JointParam, real_t);
|
|
|
|
FUNC2RC(real_t, joint_get_param, RID, JointParam);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2018-02-05 17:20:26 +00:00
|
|
|
FUNC2(joint_disable_collisions_between_bodies, RID, const bool);
|
|
|
|
FUNC1RC(bool, joint_is_disabled_collisions_between_bodies, RID);
|
|
|
|
|
2015-05-26 04:05:08 +00:00
|
|
|
///FUNC3RID(pin_joint,const Vector2&,RID,RID);
|
|
|
|
///FUNC5RID(groove_joint,const Vector2&,const Vector2&,const Vector2&,RID,RID);
|
|
|
|
///FUNC4RID(damped_spring_joint,const Vector2&,const Vector2&,RID,RID);
|
|
|
|
|
2017-11-10 02:34:01 +00:00
|
|
|
//TODO need to convert this to FUNCRID, but it's a hassle..
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3R(RID, pin_joint_create, const Vector2 &, RID, RID);
|
|
|
|
FUNC5R(RID, groove_joint_create, const Vector2 &, const Vector2 &, const Vector2 &, RID, RID);
|
|
|
|
FUNC4R(RID, damped_spring_joint_create, const Vector2 &, const Vector2 &, RID, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3(pin_joint_set_param, RID, PinJointParam, real_t);
|
|
|
|
FUNC2RC(real_t, pin_joint_get_param, RID, PinJointParam);
|
2015-10-10 20:28:05 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC3(damped_string_joint_set_param, RID, DampedStringParam, real_t);
|
|
|
|
FUNC2RC(real_t, damped_string_joint_get_param, RID, DampedStringParam);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC1RC(JointType, joint_get_type, RID);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
|
|
|
/* MISC */
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
FUNC1(free, RID);
|
|
|
|
FUNC1(set_active, bool);
|
2020-05-01 07:33:00 +00:00
|
|
|
FUNC1(set_collision_iterations, int);
|
2015-05-26 04:05:08 +00:00
|
|
|
|
|
|
|
virtual void init();
|
2017-02-13 23:25:05 +00:00
|
|
|
virtual void step(real_t p_step);
|
2015-05-26 04:05:08 +00:00
|
|
|
virtual void sync();
|
|
|
|
virtual void end_sync();
|
|
|
|
virtual void flush_queries();
|
|
|
|
virtual void finish();
|
|
|
|
|
2018-11-16 11:49:26 +00:00
|
|
|
virtual bool is_flushing_queries() const {
|
|
|
|
return physics_2d_server->is_flushing_queries();
|
|
|
|
}
|
|
|
|
|
2015-05-26 04:05:08 +00:00
|
|
|
int get_process_info(ProcessInfo p_info) {
|
|
|
|
return physics_2d_server->get_process_info(p_info);
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Physics2DServerWrapMT(Physics2DServer *p_contained, bool p_create_thread);
|
2015-05-26 04:05:08 +00:00
|
|
|
~Physics2DServerWrapMT();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
template <class T>
|
|
|
|
static Physics2DServer *init_server() {
|
2020-09-23 09:24:01 +00:00
|
|
|
#ifdef NO_THREADS
|
|
|
|
return memnew(T); // Always single unsafe when no threads are available.
|
|
|
|
#else
|
2017-03-05 15:44:50 +00:00
|
|
|
int tm = GLOBAL_DEF("physics/2d/thread_model", 1);
|
2021-05-05 10:44:11 +00:00
|
|
|
if (tm == 0) { // single unsafe
|
2017-03-05 15:44:50 +00:00
|
|
|
return memnew(T);
|
2021-05-05 10:44:11 +00:00
|
|
|
} else if (tm == 1) { // single safe
|
2017-03-05 15:44:50 +00:00
|
|
|
return memnew(Physics2DServerWrapMT(memnew(T), false));
|
2021-05-05 10:44:11 +00:00
|
|
|
} else { // multi threaded
|
2017-03-05 15:44:50 +00:00
|
|
|
return memnew(Physics2DServerWrapMT(memnew(T), true));
|
2021-05-05 10:44:11 +00:00
|
|
|
}
|
2020-09-23 09:24:01 +00:00
|
|
|
#endif
|
2015-05-26 04:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef ServerNameWrapMT
|
|
|
|
#undef ServerName
|
|
|
|
#undef server_name
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef DEBUG_SYNC
|
|
|
|
#undef DEBUG_SYNC
|
|
|
|
#endif
|
|
|
|
#undef SYNC_DEBUG
|
|
|
|
|
2022-07-25 10:33:41 +00:00
|
|
|
#endif // PHYSICS_2D_SERVER_WRAP_MT_H
|