Reworked how servers preallocate RIDs, should fix #10970
This commit is contained in:
parent
0de6cba7e7
commit
192a4d7de5
|
@ -76,11 +76,11 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>
|
|||
//VS::get_singleton()->camera_set_perspective(camera,45,0.1,10);
|
||||
VS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0);
|
||||
|
||||
RID light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL);
|
||||
RID light = VS::get_singleton()->directional_light_create();
|
||||
RID light_instance = VS::get_singleton()->instance_create2(light, scenario);
|
||||
VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
|
||||
|
||||
RID light2 = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL);
|
||||
RID light2 = VS::get_singleton()->directional_light_create();
|
||||
VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
|
||||
//VS::get_singleton()->light_set_color(light2, VS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0));
|
||||
RID light_instance2 = VS::get_singleton()->instance_create2(light2, scenario);
|
||||
|
|
|
@ -278,11 +278,11 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() {
|
|||
VS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3)));
|
||||
VS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10);
|
||||
|
||||
light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL);
|
||||
light = VS::get_singleton()->directional_light_create();
|
||||
light_instance = VS::get_singleton()->instance_create2(light, scenario);
|
||||
VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
|
||||
|
||||
light2 = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL);
|
||||
light2 = VS::get_singleton()->directional_light_create();
|
||||
VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
|
||||
//VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
|
||||
|
||||
|
@ -850,11 +850,11 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() {
|
|||
//VS::get_singleton()->camera_set_perspective(camera,45,0.1,10);
|
||||
VS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0);
|
||||
|
||||
light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL);
|
||||
light = VS::get_singleton()->directional_light_create();
|
||||
light_instance = VS::get_singleton()->instance_create2(light, scenario);
|
||||
VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
|
||||
|
||||
light2 = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL);
|
||||
light2 = VS::get_singleton()->directional_light_create();
|
||||
VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
|
||||
//VS::get_singleton()->light_set_color(light2, VS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0));
|
||||
light_instance2 = VS::get_singleton()->instance_create2(light2, scenario);
|
||||
|
|
|
@ -299,7 +299,7 @@ public:
|
|||
VisualServer *vs = VisualServer::get_singleton();
|
||||
|
||||
/* LIGHT */
|
||||
RID lightaux = vs->light_create(VisualServer::LIGHT_DIRECTIONAL);
|
||||
RID lightaux = vs->directional_light_create();
|
||||
scenario = vs->scenario_create();
|
||||
vs->light_set_shadow(lightaux, true);
|
||||
light = vs->instance_create2(lightaux, scenario);
|
||||
|
|
|
@ -86,7 +86,7 @@ class TestPhysics2DMainLoop : public MainLoop {
|
|||
|
||||
body_shape_data[Physics2DServer::SHAPE_SEGMENT].image = vs->texture_create_from_image(image);
|
||||
|
||||
RID segment_shape = ps->shape_create(Physics2DServer::SHAPE_SEGMENT);
|
||||
RID segment_shape = ps->segment_shape_create();
|
||||
Rect2 sg(Point2(-16, 0), Point2(16, 0));
|
||||
ps->shape_set_data(segment_shape, sg);
|
||||
|
||||
|
@ -113,7 +113,7 @@ class TestPhysics2DMainLoop : public MainLoop {
|
|||
|
||||
body_shape_data[Physics2DServer::SHAPE_CIRCLE].image = vs->texture_create_from_image(image);
|
||||
|
||||
RID circle_shape = ps->shape_create(Physics2DServer::SHAPE_CIRCLE);
|
||||
RID circle_shape = ps->circle_shape_create();
|
||||
ps->shape_set_data(circle_shape, 16);
|
||||
|
||||
body_shape_data[Physics2DServer::SHAPE_CIRCLE].shape = circle_shape;
|
||||
|
@ -140,7 +140,7 @@ class TestPhysics2DMainLoop : public MainLoop {
|
|||
|
||||
body_shape_data[Physics2DServer::SHAPE_RECTANGLE].image = vs->texture_create_from_image(image);
|
||||
|
||||
RID rectangle_shape = ps->shape_create(Physics2DServer::SHAPE_RECTANGLE);
|
||||
RID rectangle_shape = ps->rectangle_shape_create();
|
||||
ps->shape_set_data(rectangle_shape, Vector2(16, 16));
|
||||
|
||||
body_shape_data[Physics2DServer::SHAPE_RECTANGLE].shape = rectangle_shape;
|
||||
|
@ -168,7 +168,7 @@ class TestPhysics2DMainLoop : public MainLoop {
|
|||
|
||||
body_shape_data[Physics2DServer::SHAPE_CAPSULE].image = vs->texture_create_from_image(image);
|
||||
|
||||
RID capsule_shape = ps->shape_create(Physics2DServer::SHAPE_CAPSULE);
|
||||
RID capsule_shape = ps->capsule_shape_create();
|
||||
ps->shape_set_data(capsule_shape, Vector2(16, 32));
|
||||
|
||||
body_shape_data[Physics2DServer::SHAPE_CAPSULE].shape = capsule_shape;
|
||||
|
@ -182,7 +182,7 @@ class TestPhysics2DMainLoop : public MainLoop {
|
|||
|
||||
body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].image = vs->texture_create_from_image(image);
|
||||
|
||||
RID convex_polygon_shape = ps->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON);
|
||||
RID convex_polygon_shape = ps->convex_polygon_shape_create();
|
||||
|
||||
PoolVector<Vector2> arr;
|
||||
Point2 sb(32, 32);
|
||||
|
@ -277,10 +277,11 @@ protected:
|
|||
arr.push_back(p_normal);
|
||||
arr.push_back(p_d);
|
||||
|
||||
RID plane = ps->shape_create(Physics2DServer::SHAPE_LINE);
|
||||
RID plane = ps->line_shape_create();
|
||||
ps->shape_set_data(plane, arr);
|
||||
|
||||
RID plane_body = ps->body_create(Physics2DServer::BODY_MODE_STATIC);
|
||||
RID plane_body = ps->body_create();
|
||||
ps->body_set_mode(plane_body, Physics2DServer::BODY_MODE_STATIC);
|
||||
ps->body_set_space(plane_body, space);
|
||||
ps->body_add_shape(plane_body, plane);
|
||||
}
|
||||
|
@ -290,9 +291,10 @@ protected:
|
|||
Physics2DServer *ps = Physics2DServer::get_singleton();
|
||||
VisualServer *vs = VisualServer::get_singleton();
|
||||
|
||||
RID concave = ps->shape_create(Physics2DServer::SHAPE_CONCAVE_POLYGON);
|
||||
RID concave = ps->concave_polygon_shape_create();
|
||||
ps->shape_set_data(concave, p_points);
|
||||
RID body = ps->body_create(Physics2DServer::BODY_MODE_STATIC);
|
||||
RID body = ps->body_create();
|
||||
ps->body_set_mode(body, Physics2DServer::BODY_MODE_STATIC);
|
||||
ps->body_set_space(body, space);
|
||||
ps->body_add_shape(body, concave);
|
||||
ps->body_set_state(body, Physics2DServer::BODY_STATE_TRANSFORM, p_xform);
|
||||
|
|
|
@ -180,7 +180,7 @@ public:
|
|||
*/
|
||||
RID lightaux;
|
||||
|
||||
lightaux = vs->light_create(VisualServer::LIGHT_DIRECTIONAL);
|
||||
lightaux = vs->directional_light_create();
|
||||
//vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
|
||||
vs->light_set_color(lightaux, Color(1.0, 1.0, 1.0));
|
||||
//vs->light_set_shadow( lightaux, true );
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
|
||||
vs->instance_set_transform(light, lla);
|
||||
|
||||
lightaux = vs->light_create(VisualServer::LIGHT_OMNI);
|
||||
lightaux = vs->omni_light_create();
|
||||
//vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) );
|
||||
vs->light_set_color(lightaux, Color(1.0, 1.0, 0.0));
|
||||
vs->light_set_param(lightaux, VisualServer::LIGHT_PARAM_RANGE, 4);
|
||||
|
|
|
@ -133,8 +133,9 @@ bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const {
|
|||
}
|
||||
|
||||
PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode)
|
||||
: CollisionObject2D(Physics2DServer::get_singleton()->body_create(p_mode), false) {
|
||||
: CollisionObject2D(Physics2DServer::get_singleton()->body_create(), false) {
|
||||
|
||||
Physics2DServer::get_singleton()->body_set_mode(get_rid(), p_mode);
|
||||
collision_layer = 1;
|
||||
collision_mask = 1;
|
||||
set_pickable(false);
|
||||
|
|
|
@ -587,7 +587,9 @@ Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(cons
|
|||
|
||||
xform.set_origin(q.pos);
|
||||
//q.canvas_item = VisualServer::get_singleton()->canvas_item_create();
|
||||
q.body = Physics2DServer::get_singleton()->body_create(use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC);
|
||||
q.body = Physics2DServer::get_singleton()->body_create();
|
||||
Physics2DServer::get_singleton()->body_set_mode(q.body, use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC);
|
||||
|
||||
Physics2DServer::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id());
|
||||
Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer);
|
||||
Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask);
|
||||
|
|
|
@ -255,7 +255,13 @@ void Light::_bind_methods() {
|
|||
Light::Light(VisualServer::LightType p_type) {
|
||||
|
||||
type = p_type;
|
||||
light = VisualServer::get_singleton()->light_create(p_type);
|
||||
switch (p_type) {
|
||||
case VS::LIGHT_DIRECTIONAL: light = VisualServer::get_singleton()->directional_light_create(); break;
|
||||
case VS::LIGHT_OMNI: light = VisualServer::get_singleton()->omni_light_create(); break;
|
||||
case VS::LIGHT_SPOT: light = VisualServer::get_singleton()->spot_light_create(); break;
|
||||
default: {};
|
||||
}
|
||||
|
||||
VS::get_singleton()->instance_set_base(get_instance(), light);
|
||||
|
||||
reverse_cull = false;
|
||||
|
|
|
@ -995,7 +995,7 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
|
|||
Transform gt = get_global_transform();
|
||||
gt.origin -= collision.travel;
|
||||
set_global_transform(gt);
|
||||
return floor_velocity;
|
||||
return floor_velocity - p_floor_direction * p_floor_direction.dot(floor_velocity);
|
||||
}
|
||||
} else if (collision.normal.dot(-p_floor_direction) >= Math::cos(p_floor_max_angle)) { //ceiling
|
||||
on_ceiling = true;
|
||||
|
|
|
@ -98,7 +98,7 @@ void CapsuleShape2D::_bind_methods() {
|
|||
}
|
||||
|
||||
CapsuleShape2D::CapsuleShape2D()
|
||||
: Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CAPSULE)) {
|
||||
: Shape2D(Physics2DServer::get_singleton()->capsule_shape_create()) {
|
||||
|
||||
radius = 10;
|
||||
height = 20;
|
||||
|
|
|
@ -77,7 +77,7 @@ void CircleShape2D::draw(const RID &p_to_rid, const Color &p_color) {
|
|||
}
|
||||
|
||||
CircleShape2D::CircleShape2D()
|
||||
: Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CIRCLE)) {
|
||||
: Shape2D(Physics2DServer::get_singleton()->circle_shape_create()) {
|
||||
|
||||
radius = 10;
|
||||
_update_shape();
|
||||
|
|
|
@ -85,5 +85,5 @@ void ConcavePolygonShape2D::_bind_methods() {
|
|||
}
|
||||
|
||||
ConcavePolygonShape2D::ConcavePolygonShape2D()
|
||||
: Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONCAVE_POLYGON)) {
|
||||
: Shape2D(Physics2DServer::get_singleton()->concave_polygon_shape_create()) {
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ Rect2 ConvexPolygonShape2D::get_rect() const {
|
|||
}
|
||||
|
||||
ConvexPolygonShape2D::ConvexPolygonShape2D()
|
||||
: Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON)) {
|
||||
: Shape2D(Physics2DServer::get_singleton()->convex_polygon_shape_create()) {
|
||||
|
||||
int pcount = 3;
|
||||
for (int i = 0; i < pcount; i++)
|
||||
|
|
|
@ -67,7 +67,7 @@ void RectangleShape2D::_bind_methods() {
|
|||
}
|
||||
|
||||
RectangleShape2D::RectangleShape2D()
|
||||
: Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RECTANGLE)) {
|
||||
: Shape2D(Physics2DServer::get_singleton()->rectangle_shape_create()) {
|
||||
|
||||
extents = Vector2(10, 10);
|
||||
_update_shape();
|
||||
|
|
|
@ -87,7 +87,7 @@ void SegmentShape2D::_bind_methods() {
|
|||
}
|
||||
|
||||
SegmentShape2D::SegmentShape2D()
|
||||
: Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_SEGMENT)) {
|
||||
: Shape2D(Physics2DServer::get_singleton()->segment_shape_create()) {
|
||||
|
||||
a = Vector2();
|
||||
b = Vector2(0, 10);
|
||||
|
@ -146,7 +146,7 @@ real_t RayShape2D::get_length() const {
|
|||
}
|
||||
|
||||
RayShape2D::RayShape2D()
|
||||
: Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RAY)) {
|
||||
: Shape2D(Physics2DServer::get_singleton()->ray_shape_create()) {
|
||||
|
||||
length = 20;
|
||||
_update_shape();
|
||||
|
|
|
@ -96,7 +96,7 @@ void LineShape2D::_bind_methods() {
|
|||
}
|
||||
|
||||
LineShape2D::LineShape2D()
|
||||
: Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_LINE)) {
|
||||
: Shape2D(Physics2DServer::get_singleton()->line_shape_create()) {
|
||||
|
||||
normal = Vector2(0, -1);
|
||||
d = 0;
|
||||
|
|
|
@ -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) {
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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> &)
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue