summaryrefslogtreecommitdiff
path: root/servers
diff options
context:
space:
mode:
Diffstat (limited to 'servers')
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp47
-rw-r--r--servers/physics_2d/physics_2d_server_sw.h15
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.cpp27
-rw-r--r--servers/physics_2d/physics_2d_server_wrap_mt.h33
-rw-r--r--servers/physics_2d_server.cpp10
-rw-r--r--servers/physics_2d_server.h12
-rw-r--r--servers/visual/rasterizer.h4
-rw-r--r--servers/visual/visual_server_raster.h4
-rw-r--r--servers/visual/visual_server_wrap_mt.cpp26
-rw-r--r--servers/visual/visual_server_wrap_mt.h42
-rw-r--r--servers/visual_server.h4
11 files changed, 155 insertions, 69 deletions
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index 5d3305c82d..475a3fe3b3 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -35,7 +35,7 @@
#include "project_settings.h"
#include "script_language.h"
-RID Physics2DServerSW::shape_create(ShapeType p_shape) {
+RID Physics2DServerSW::_shape_create(ShapeType p_shape) {
Shape2DSW *shape = NULL;
switch (p_shape) {
@@ -83,7 +83,42 @@ RID Physics2DServerSW::shape_create(ShapeType p_shape) {
shape->set_self(id);
return id;
-};
+}
+
+RID Physics2DServerSW::line_shape_create() {
+
+ return _shape_create(SHAPE_LINE);
+}
+
+RID Physics2DServerSW::ray_shape_create() {
+
+ return _shape_create(SHAPE_RAY);
+}
+RID Physics2DServerSW::segment_shape_create() {
+
+ return _shape_create(SHAPE_SEGMENT);
+}
+RID Physics2DServerSW::circle_shape_create() {
+
+ return _shape_create(SHAPE_CIRCLE);
+}
+RID Physics2DServerSW::rectangle_shape_create() {
+
+ return _shape_create(SHAPE_RECTANGLE);
+}
+RID Physics2DServerSW::capsule_shape_create() {
+
+ return _shape_create(SHAPE_CAPSULE);
+}
+
+RID Physics2DServerSW::convex_polygon_shape_create() {
+
+ return _shape_create(SHAPE_CONVEX_POLYGON);
+}
+RID Physics2DServerSW::concave_polygon_shape_create() {
+
+ return _shape_create(SHAPE_CONCAVE_POLYGON);
+}
void Physics2DServerSW::shape_set_data(RID p_shape, const Variant &p_data) {
@@ -519,17 +554,13 @@ void Physics2DServerSW::area_set_area_monitor_callback(RID p_area, Object *p_rec
/* BODY API */
-RID Physics2DServerSW::body_create(BodyMode p_mode, bool p_init_sleeping) {
+RID Physics2DServerSW::body_create() {
Body2DSW *body = memnew(Body2DSW);
- if (p_mode != BODY_MODE_RIGID)
- body->set_mode(p_mode);
- if (p_init_sleeping)
- body->set_state(BODY_STATE_SLEEPING, p_init_sleeping);
RID rid = body_owner.make_rid(body);
body->set_self(rid);
return rid;
-};
+}
void Physics2DServerSW::body_set_space(RID p_body, RID p_space) {
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h
index c40cf0e3e0..171a0b7a81 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_2d_server_sw.h
@@ -67,6 +67,9 @@ class Physics2DServerSW : public Physics2DServer {
static Physics2DServerSW *singletonsw;
//void _clear_query(Query2DSW *p_query);
+
+ RID _shape_create(ShapeType p_shape);
+
public:
struct CollCbkData {
@@ -78,9 +81,17 @@ public:
Vector2 *ptr;
};
+ virtual RID line_shape_create();
+ virtual RID ray_shape_create();
+ virtual RID segment_shape_create();
+ virtual RID circle_shape_create();
+ virtual RID rectangle_shape_create();
+ virtual RID capsule_shape_create();
+ virtual RID convex_polygon_shape_create();
+ virtual RID concave_polygon_shape_create();
+
static void _shape_col_cbk(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_userdata);
- virtual RID shape_create(ShapeType p_shape);
virtual void shape_set_data(RID p_shape, const Variant &p_data);
virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias);
@@ -149,7 +160,7 @@ public:
/* BODY API */
// create a body of a given type
- virtual RID body_create(BodyMode p_mode = BODY_MODE_RIGID, bool p_init_sleeping = false);
+ virtual RID body_create();
virtual void body_set_space(RID p_body, RID p_space);
virtual RID body_get_space(RID p_body) const;
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp
index f8f3b620d4..f92ed18de2 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp
@@ -130,19 +130,23 @@ void Physics2DServerWrapMT::finish() {
Thread::wait_to_finish(thread);
memdelete(thread);
- /*
- shape_free_cached_ids();
- area_free_cached_ids();
- body_free_cached_ids();
- pin_joint_free_cached_ids();
- groove_joint_free_cached_ids();
- damped_string_free_cached_ids();
-*/
thread = NULL;
} else {
physics_2d_server->finish();
}
+ line_shape_free_cached_ids();
+ ray_shape_free_cached_ids();
+ segment_shape_free_cached_ids();
+ circle_shape_free_cached_ids();
+ rectangle_shape_free_cached_ids();
+ convex_polygon_shape_free_cached_ids();
+ concave_polygon_shape_free_cached_ids();
+
+ space_free_cached_ids();
+ area_free_cached_ids();
+ body_free_cached_ids();
+
if (step_sem)
memdelete(step_sem);
}
@@ -158,12 +162,7 @@ Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool
step_thread_up = false;
alloc_mutex = Mutex::create();
- shape_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
- area_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
- body_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
- pin_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
- groove_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
- damped_spring_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
+ pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
if (!p_create_thread) {
server_thread = Thread::get_caller_id();
diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h
index 50e9ab1005..cbc316cb7a 100644
--- a/servers/physics_2d/physics_2d_server_wrap_mt.h
+++ b/servers/physics_2d/physics_2d_server_wrap_mt.h
@@ -64,21 +64,10 @@ class Physics2DServerWrapMT : public Physics2DServer {
void thread_exit();
- Mutex *alloc_mutex;
bool first_frame;
- int shape_pool_max_size;
- List<RID> shape_id_pool;
- int area_pool_max_size;
- List<RID> area_id_pool;
- int body_pool_max_size;
- List<RID> body_id_pool;
- int pin_joint_pool_max_size;
- List<RID> pin_joint_id_pool;
- int groove_joint_pool_max_size;
- List<RID> groove_joint_id_pool;
- int damped_spring_joint_pool_max_size;
- List<RID> damped_spring_joint_id_pool;
+ Mutex *alloc_mutex;
+ int pool_max_size;
public:
#define ServerName Physics2DServer
@@ -87,7 +76,15 @@ public:
#include "servers/server_wrap_mt_common.h"
//FUNC1RID(shape,ShapeType); todo fix
- FUNC1R(RID, shape_create, ShapeType);
+ 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)
+
FUNC2(shape_set_data, RID, const Variant &);
FUNC2(shape_set_custom_solver_bias, RID, real_t);
@@ -104,7 +101,7 @@ public:
/* SPACE API */
- FUNC0R(RID, space_create);
+ FUNCRID(space);
FUNC2(space_set_active, RID, bool);
FUNC1RC(bool, space_is_active, RID);
@@ -134,7 +131,7 @@ public:
/* AREA API */
//FUNC0RID(area);
- FUNC0R(RID, area_create);
+ FUNCRID(area);
FUNC2(area_set_space, RID, RID);
FUNC1RC(RID, area_get_space, RID);
@@ -174,7 +171,7 @@ public:
/* BODY API */
//FUNC2RID(body,BodyMode,bool);
- FUNC2R(RID, body_create, BodyMode, bool)
+ FUNCRID(body)
FUNC2(body_set_space, RID, RID);
FUNC1RC(RID, body_get_space, RID);
@@ -269,6 +266,8 @@ public:
///FUNC5RID(groove_joint,const Vector2&,const Vector2&,const Vector2&,RID,RID);
///FUNC4RID(damped_spring_joint,const Vector2&,const Vector2&,RID,RID);
+ //TODO need to convert this to FUNCRID, but it's a hassle..
+
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);
diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp
index 130c0583dc..a5128c9435 100644
--- a/servers/physics_2d_server.cpp
+++ b/servers/physics_2d_server.cpp
@@ -475,7 +475,15 @@ bool Physics2DServer::_body_test_motion(RID p_body, const Transform2D &p_from, c
void Physics2DServer::_bind_methods() {
- ClassDB::bind_method(D_METHOD("shape_create", "type"), &Physics2DServer::shape_create);
+ ClassDB::bind_method(D_METHOD("line_shape_create"), &Physics2DServer::line_shape_create);
+ ClassDB::bind_method(D_METHOD("ray_shape_create"), &Physics2DServer::ray_shape_create);
+ ClassDB::bind_method(D_METHOD("segment_shape_create"), &Physics2DServer::segment_shape_create);
+ ClassDB::bind_method(D_METHOD("circle_shape_create"), &Physics2DServer::circle_shape_create);
+ ClassDB::bind_method(D_METHOD("rectangle_shape_create"), &Physics2DServer::rectangle_shape_create);
+ ClassDB::bind_method(D_METHOD("capsule_shape_create"), &Physics2DServer::capsule_shape_create);
+ ClassDB::bind_method(D_METHOD("convex_polygon_shape_create"), &Physics2DServer::convex_polygon_shape_create);
+ ClassDB::bind_method(D_METHOD("concave_polygon_shape_create"), &Physics2DServer::concave_polygon_shape_create);
+
ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &Physics2DServer::shape_set_data);
ClassDB::bind_method(D_METHOD("shape_get_type", "shape"), &Physics2DServer::shape_get_type);
diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h
index ddd1555768..241255bdb5 100644
--- a/servers/physics_2d_server.h
+++ b/servers/physics_2d_server.h
@@ -252,7 +252,15 @@ public:
SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error
};
- virtual RID shape_create(ShapeType p_shape) = 0;
+ virtual RID line_shape_create() = 0;
+ virtual RID ray_shape_create() = 0;
+ virtual RID segment_shape_create() = 0;
+ virtual RID circle_shape_create() = 0;
+ virtual RID rectangle_shape_create() = 0;
+ virtual RID capsule_shape_create() = 0;
+ virtual RID convex_polygon_shape_create() = 0;
+ virtual RID concave_polygon_shape_create() = 0;
+
virtual void shape_set_data(RID p_shape, const Variant &p_data) = 0;
virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias) = 0;
@@ -366,7 +374,7 @@ public:
//BODY_MODE_SOFT ??
};
- virtual RID body_create(BodyMode p_mode = BODY_MODE_RIGID, bool p_init_sleeping = false) = 0;
+ virtual RID body_create() = 0;
virtual void body_set_space(RID p_body, RID p_space) = 0;
virtual RID body_get_space(RID p_body) const = 0;
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index cd4b465d79..164baa8c9b 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -320,6 +320,10 @@ public:
virtual RID light_create(VS::LightType p_type) = 0;
+ RID directional_light_create() { return light_create(VS::LIGHT_DIRECTIONAL); }
+ RID omni_light_create() { return light_create(VS::LIGHT_OMNI); }
+ RID spot_light_create() { return light_create(VS::LIGHT_SPOT); }
+
virtual void light_set_color(RID p_light, const Color &p_color) = 0;
virtual void light_set_param(RID p_light, VS::LightParam p_param, float p_value) = 0;
virtual void light_set_shadow(RID p_light, bool p_enabled) = 0;
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 425381550e..b579f4032f 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -799,7 +799,9 @@ public:
/* Light API */
- BIND1R(RID, light_create, LightType)
+ BIND0R(RID, directional_light_create)
+ BIND0R(RID, omni_light_create)
+ BIND0R(RID, spot_light_create)
BIND2(light_set_color, RID, const Color &)
BIND3(light_set_param, RID, LightParam, float)
diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp
index d9a0077e60..1a03c72529 100644
--- a/servers/visual/visual_server_wrap_mt.cpp
+++ b/servers/visual/visual_server_wrap_mt.cpp
@@ -154,14 +154,34 @@ void VisualServerWrapMT::finish() {
Thread::wait_to_finish(thread);
memdelete(thread);
- texture_free_cached_ids();
- //mesh_free_cached_ids();
-
thread = NULL;
} else {
visual_server->finish();
}
+ texture_free_cached_ids();
+ shader_free_cached_ids();
+ material_free_cached_ids();
+ mesh_free_cached_ids();
+ multimesh_free_cached_ids();
+ immediate_free_cached_ids();
+ skeleton_free_cached_ids();
+ directional_light_free_cached_ids();
+ omni_light_free_cached_ids();
+ spot_light_free_cached_ids();
+ reflection_probe_free_cached_ids();
+ gi_probe_free_cached_ids();
+ particles_free_cached_ids();
+ camera_free_cached_ids();
+ viewport_free_cached_ids();
+ environment_free_cached_ids();
+ scenario_free_cached_ids();
+ instance_free_cached_ids();
+ canvas_free_cached_ids();
+ canvas_item_free_cached_ids();
+ canvas_light_occluder_free_cached_ids();
+ canvas_occluder_polygon_free_cached_ids();
+
if (draw_mutex)
memdelete(draw_mutex);
}
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index 67d503dfca..80a1ef3879 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -103,12 +103,12 @@ public:
/* SKY API */
- FUNC0R(RID, sky_create)
+ FUNCRID(sky)
FUNC3(sky_set_texture, RID, RID, int)
/* SHADER API */
- FUNC0R(RID, shader_create)
+ FUNCRID(shader)
FUNC2(shader_set_code, RID, const String &)
FUNC1RC(String, shader_get_code, RID)
@@ -120,7 +120,7 @@ public:
/* COMMON MATERIAL API */
- FUNC0R(RID, material_create)
+ FUNCRID(material)
FUNC2(material_set_shader, RID, RID)
FUNC1RC(RID, material_get_shader, RID)
@@ -134,7 +134,7 @@ public:
/* MESH API */
- FUNC0R(RID, mesh_create)
+ FUNCRID(mesh)
FUNC10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const Rect3 &, const Vector<PoolVector<uint8_t> > &, const Vector<Rect3> &)
@@ -170,7 +170,7 @@ public:
/* MULTIMESH API */
- FUNC0R(RID, multimesh_create)
+ FUNCRID(multimesh)
FUNC4(multimesh_allocate, RID, int, MultimeshTransformFormat, MultimeshColorFormat)
FUNC1RC(int, multimesh_get_instance_count, RID)
@@ -192,7 +192,7 @@ public:
/* IMMEDIATE API */
- FUNC0R(RID, immediate_create)
+ FUNCRID(immediate)
FUNC3(immediate_begin, RID, PrimitiveType, RID)
FUNC2(immediate_vertex, RID, const Vector3 &)
FUNC2(immediate_normal, RID, const Vector3 &)
@@ -207,7 +207,7 @@ public:
/* SKELETON API */
- FUNC0R(RID, skeleton_create)
+ FUNCRID(skeleton)
FUNC3(skeleton_allocate, RID, int, bool)
FUNC1RC(int, skeleton_get_bone_count, RID)
FUNC3(skeleton_bone_set_transform, RID, int, const Transform &)
@@ -217,7 +217,9 @@ public:
/* Light API */
- FUNC1R(RID, light_create, LightType)
+ FUNCRID(directional_light)
+ FUNCRID(omni_light)
+ FUNCRID(spot_light)
FUNC2(light_set_color, RID, const Color &)
FUNC3(light_set_param, RID, LightParam, float)
@@ -237,7 +239,7 @@ public:
/* PROBE API */
- FUNC0R(RID, reflection_probe_create)
+ FUNCRID(reflection_probe)
FUNC2(reflection_probe_set_update_mode, RID, ReflectionProbeUpdateMode)
FUNC2(reflection_probe_set_intensity, RID, float)
@@ -254,7 +256,7 @@ public:
/* BAKED LIGHT API */
- FUNC0R(RID, gi_probe_create)
+ FUNCRID(gi_probe)
FUNC2(gi_probe_set_bounds, RID, const Rect3 &)
FUNC1RC(Rect3, gi_probe_get_bounds, RID)
@@ -291,7 +293,7 @@ public:
/* PARTICLES */
- FUNC0R(RID, particles_create)
+ FUNCRID(particles)
FUNC2(particles_set_emitting, RID, bool)
FUNC2(particles_set_amount, RID, int)
@@ -318,7 +320,7 @@ public:
/* CAMERA API */
- FUNC0R(RID, camera_create)
+ FUNCRID(camera)
FUNC4(camera_set_perspective, RID, float, float, float)
FUNC4(camera_set_orthogonal, RID, float, float, float)
FUNC2(camera_set_transform, RID, const Transform &)
@@ -328,7 +330,7 @@ public:
/* VIEWPORT TARGET API */
- FUNC0R(RID, viewport_create)
+ FUNCRID(viewport)
FUNC2(viewport_set_use_arvr, RID, bool)
@@ -377,7 +379,7 @@ public:
/* ENVIRONMENT API */
- FUNC0R(RID, environment_create)
+ FUNCRID(environment)
FUNC2(environment_set_background, RID, EnvironmentBG)
FUNC2(environment_set_sky, RID, RID)
@@ -401,7 +403,7 @@ public:
FUNC6(environment_set_fog_depth, RID, bool, float, float, bool, float)
FUNC5(environment_set_fog_height, RID, bool, float, float, float)
- FUNC0R(RID, scenario_create)
+ FUNCRID(scenario)
FUNC2(scenario_set_debug, RID, ScenarioDebugMode)
FUNC2(scenario_set_environment, RID, RID)
@@ -410,7 +412,7 @@ public:
/* INSTANCING API */
// from can be mesh, light, area and portal so far.
- FUNC0R(RID, instance_create)
+ FUNCRID(instance)
FUNC2(instance_set_base, RID, RID) // from can be mesh, light, poly, area and portal so far.
FUNC2(instance_set_scenario, RID, RID) // from can be mesh, light, poly, area and portal so far.
@@ -440,11 +442,11 @@ public:
/* CANVAS (2D) */
- FUNC0R(RID, canvas_create)
+ FUNCRID(canvas)
FUNC3(canvas_set_item_mirroring, RID, RID, const Point2 &)
FUNC2(canvas_set_modulate, RID, const Color &)
- FUNC0R(RID, canvas_item_create)
+ FUNCRID(canvas_item)
FUNC2(canvas_item_set_parent, RID, RID)
FUNC2(canvas_item_set_visible, RID, bool)
@@ -510,14 +512,14 @@ public:
FUNC2(canvas_light_set_shadow_color, RID, const Color &)
FUNC2(canvas_light_set_shadow_smooth, RID, float)
- FUNC0R(RID, canvas_light_occluder_create)
+ FUNCRID(canvas_light_occluder)
FUNC2(canvas_light_occluder_attach_to_canvas, RID, RID)
FUNC2(canvas_light_occluder_set_enabled, RID, bool)
FUNC2(canvas_light_occluder_set_polygon, RID, RID)
FUNC2(canvas_light_occluder_set_transform, RID, const Transform2D &)
FUNC2(canvas_light_occluder_set_light_mask, RID, int)
- FUNC0R(RID, canvas_occluder_polygon_create)
+ FUNCRID(canvas_occluder_polygon)
FUNC3(canvas_occluder_polygon_set_shape, RID, const PoolVector<Vector2> &, bool)
FUNC2(canvas_occluder_polygon_set_shape_as_lines, RID, const PoolVector<Vector2> &)
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 64ed540501..86c32a45a0 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -373,7 +373,9 @@ public:
LIGHT_PARAM_MAX
};
- virtual RID light_create(LightType p_type) = 0;
+ virtual RID directional_light_create() = 0;
+ virtual RID omni_light_create() = 0;
+ virtual RID spot_light_create() = 0;
virtual void light_set_color(RID p_light, const Color &p_color) = 0;
virtual void light_set_param(RID p_light, LightParam p_param, float p_value) = 0;