ability to run 2D physics in a thread

also, 2D physics is now thread safe too.
see physics_2d/thread_model
This commit is contained in:
Juan Linietsky 2015-05-26 01:05:08 -03:00
parent 3826b66a6e
commit 9df77d2765
24 changed files with 1220 additions and 573 deletions

View file

@ -1460,6 +1460,7 @@ Globals::Globals() {
custom_prop_info["display/orientation"]=PropertyInfo(Variant::STRING,"display/orientation",PROPERTY_HINT_ENUM,"landscape,portrait,reverse_landscape,reverse_portrait,sensor_landscape,sensor_portrait,sensor");
custom_prop_info["render/mipmap_policy"]=PropertyInfo(Variant::INT,"render/mipmap_policy",PROPERTY_HINT_ENUM,"Allow,Allow For Po2,Disallow");
custom_prop_info["render/thread_model"]=PropertyInfo(Variant::INT,"render/thread_model",PROPERTY_HINT_ENUM,"Single-Unsafe,Single-Safe,Multi-Threaded");
custom_prop_info["physics_2d/thread_model"]=PropertyInfo(Variant::INT,"physics_2d/thread_model",PROPERTY_HINT_ENUM,"Single-Unsafe,Single-Safe,Multi-Threaded");
set("display/emulate_touchscreen",false);
using_datapack=false;

View file

@ -28,6 +28,7 @@ spawn=[key(F1), jbutton(0, 11)]
[physics_2d]
default_gravity=700
thread_model=1
[rasterizer]

View file

@ -1356,6 +1356,8 @@ bool Main::iteration() {
message_queue->flush();
PhysicsServer::get_singleton()->step(frame_slice*time_scale);
Physics2DServer::get_singleton()->end_sync();
Physics2DServer::get_singleton()->step(frame_slice*time_scale);
time_accum-=frame_slice;

View file

@ -163,7 +163,8 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_
//
physics_server = memnew( PhysicsServerSW );
physics_server->init();
physics_2d_server = memnew( Physics2DServerSW );
//physics_2d_server = memnew( Physics2DServerSW );
physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>();
physics_2d_server->init();
input = memnew( InputDefault );

View file

@ -37,6 +37,7 @@
#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
#include "servers/audio/audio_server_sw.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
#include "servers/visual/rasterizer.h"

View file

@ -136,7 +136,8 @@ void OSIPhone::initialize(const VideoMode& p_desired,int p_video_driver,int p_au
//
physics_server = memnew( PhysicsServerSW );
physics_server->init();
physics_2d_server = memnew( Physics2DServerSW );
//physics_2d_server = memnew( Physics2DServerSW );
physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>();
physics_2d_server->init();
input = memnew( InputDefault );

View file

@ -38,6 +38,7 @@
#include "servers/visual/rasterizer.h"
#include "servers/physics/physics_server_sw.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
#include "servers/audio/audio_server_sw.h"
#include "servers/audio/sample_manager_sw.h"
#include "servers/spatial_sound/spatial_sound_server_sw.h"

View file

@ -44,6 +44,7 @@
#include "drivers/rtaudio/audio_driver_rtaudio.h"
#include "drivers/alsa/audio_driver_alsa.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
#include "platform/osx/audio_driver_osx.h"
#include <ApplicationServices/ApplicationServices.h>

View file

@ -1015,7 +1015,8 @@ void OS_OSX::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
//
physics_server = memnew( PhysicsServerSW );
physics_server->init();
physics_2d_server = memnew( Physics2DServerSW );
//physics_2d_server = memnew( Physics2DServerSW );
physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>();
physics_2d_server->init();
input = memnew( InputDefault );

View file

@ -1177,7 +1177,7 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_
physics_server = memnew( PhysicsServerSW );
physics_server->init();
physics_2d_server = memnew( Physics2DServerSW );
physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>();
physics_2d_server->init();
if (!is_no_window_mode_enabled()) {
@ -1375,6 +1375,9 @@ void OS_Windows::finalize() {
physics_2d_server->finish();
memdelete(physics_2d_server);
joystick_change_queue.clear();
monitor_info.clear();
}
void OS_Windows::finalize_core() {
@ -2052,7 +2055,7 @@ String OS_Windows::get_executable_path() const {
wchar_t bufname[4096];
GetModuleFileNameW(NULL,bufname,4096);
String s= bufname;
print_line("EXEC PATHP¨®: "+s);
print_line("EXEC PATHP??: "+s);
return s;
}

View file

@ -45,6 +45,7 @@
#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
#include "drivers/unix/ip_unix.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
#include <windows.h>

View file

@ -35,6 +35,7 @@
#include "print_string.h"
#include "servers/physics/physics_server_sw.h"
#include "X11/Xutil.h"
#include "X11/Xatom.h"
@ -426,7 +427,8 @@ void OS_X11::initialize(const VideoMode& p_desired,int p_video_driver,int p_audi
//
physics_server = memnew( PhysicsServerSW );
physics_server->init();
physics_2d_server = memnew( Physics2DServerSW );
//physics_2d_server = memnew( Physics2DServerSW );
physics_2d_server = Physics2DServerWrapMT::init_server<Physics2DServerSW>();
physics_2d_server->init();
input = memnew( InputDefault );

View file

@ -45,6 +45,7 @@
#include "drivers/alsa/audio_driver_alsa.h"
#include "drivers/pulseaudio/audio_driver_pulseaudio.h"
#include "servers/physics_2d/physics_2d_server_sw.h"
#include "servers/physics_2d/physics_2d_server_wrap_mt.h"
#include <X11/keysym.h>
#include <X11/Xlib.h>

View file

@ -150,10 +150,10 @@ RES ResourceFormatLoaderWAV::load(const String &p_path,const String& p_original_
frames/=format_channels;
frames/=(format_bits>>3);
print_line("chunksize: "+itos(chunksize));
/*print_line("chunksize: "+itos(chunksize));
print_line("channels: "+itos(format_channels));
print_line("bits: "+itos(format_bits));
*/
sample->create(
(format_bits==8) ? Sample::FORMAT_PCM8 : Sample::FORMAT_PCM16,
(format_channels==2)?true:false,

View file

@ -135,7 +135,7 @@ void SampleManagerMallocSW::sample_set_data(RID p_sample, const DVector<uint8_t>
ERR_EXPLAIN("Sample buffer size does not match sample size.");
print_line("len bytes: "+itos(s->length_bytes)+" bufsize: "+itos(buff_size));
//print_line("len bytes: "+itos(s->length_bytes)+" bufsize: "+itos(buff_size));
ERR_FAIL_COND(s->length_bytes!=buff_size);
DVector<uint8_t>::Read buffer_r=p_buffer.read();
const uint8_t *src = buffer_r.ptr();

View file

@ -30,7 +30,7 @@
#include "broad_phase_2d_basic.h"
#include "broad_phase_2d_hash_grid.h"
#include "collision_solver_2d_sw.h"
#include "globals.h"
RID Physics2DServerSW::shape_create(ShapeType p_shape) {
Shape2DSW *shape=NULL;
@ -261,7 +261,7 @@ Physics2DDirectSpaceState* Physics2DServerSW::space_get_direct_state(RID p_space
Space2DSW *space = space_owner.get(p_space);
ERR_FAIL_COND_V(!space,NULL);
if (/*doing_sync ||*/ space->is_locked()) {
if ((using_threads && !doing_sync) || space->is_locked()) {
ERR_EXPLAIN("Space state is inaccesible right now, wait for iteration or fixed process notification.");
ERR_FAIL_V(NULL);
@ -733,7 +733,7 @@ void Physics2DServerSW::body_set_layer_mask(RID p_body, uint32_t p_flags) {
};
uint32_t Physics2DServerSW::body_get_layer_mask(RID p_body, uint32_t p_flags) const {
uint32_t Physics2DServerSW::body_get_layer_mask(RID p_body) const {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,0);
@ -750,7 +750,7 @@ void Physics2DServerSW::body_set_collision_mask(RID p_body, uint32_t p_flags) {
};
uint32_t Physics2DServerSW::body_get_collision_mask(RID p_body, uint32_t p_flags) const {
uint32_t Physics2DServerSW::body_get_collision_mask(RID p_body) const {
Body2DSW *body = body_owner.get(p_body);
ERR_FAIL_COND_V(!body,0);
@ -1196,7 +1196,7 @@ void Physics2DServerSW::set_active(bool p_active) {
void Physics2DServerSW::init() {
doing_sync=true;
doing_sync=false;
last_step=0.001;
iterations=8;// 8?
stepper = memnew( Step2DSW );
@ -1228,6 +1228,7 @@ void Physics2DServerSW::step(float p_step) {
void Physics2DServerSW::sync() {
doing_sync=true;
};
void Physics2DServerSW::flush_queries() {
@ -1235,7 +1236,7 @@ void Physics2DServerSW::flush_queries() {
if (!active)
return;
doing_sync=true;
for( Set<const Space2DSW*>::Element *E=active_spaces.front();E;E=E->next()) {
Space2DSW *space=(Space2DSW *)E->get();
@ -1244,6 +1245,10 @@ void Physics2DServerSW::flush_queries() {
};
void Physics2DServerSW::end_sync() {
doing_sync=false;
}
void Physics2DServerSW::finish() {
@ -1283,6 +1288,7 @@ Physics2DServerSW::Physics2DServerSW() {
island_count=0;
active_objects=0;
collision_pairs=0;
using_threads=int(Globals::get_singleton()->get("physics_2d/thread_model"))==2;
};

View file

@ -51,6 +51,8 @@ friend class Physics2DDirectSpaceStateSW;
int active_objects;
int collision_pairs;
bool using_threads;
Step2DSW *stepper;
Set<const Space2DSW*> active_spaces;
@ -179,10 +181,10 @@ public:
virtual CCDMode body_get_continuous_collision_detection_mode(RID p_body) const;
virtual void body_set_layer_mask(RID p_body, uint32_t p_mask);
virtual uint32_t body_get_layer_mask(RID p_body, uint32_t p_mask) const;
virtual uint32_t body_get_layer_mask(RID p_body) const;
virtual void body_set_collision_mask(RID p_body, uint32_t p_mask);
virtual uint32_t body_get_collision_mask(RID p_body, uint32_t p_mask) const;
virtual uint32_t body_get_collision_mask(RID p_) const;
virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value);
virtual float body_get_param(RID p_body, BodyParameter p_param) const;
@ -248,8 +250,9 @@ public:
virtual void set_active(bool p_active);
virtual void init();
virtual void step(float p_step);
virtual void sync();
virtual void sync();
virtual void flush_queries();
virtual void end_sync();
virtual void finish();
int get_process_info(ProcessInfo p_info);

View file

@ -0,0 +1,161 @@
#include "physics_2d_server_wrap_mt.h"
#include "os/os.h"
void Physics2DServerWrapMT::thread_exit() {
exit=true;
}
void Physics2DServerWrapMT::thread_step(float p_delta) {
physics_2d_server->step(p_delta);
step_sem->post();
}
void Physics2DServerWrapMT::_thread_callback(void *_instance) {
Physics2DServerWrapMT *vsmt = reinterpret_cast<Physics2DServerWrapMT*>(_instance);
vsmt->thread_loop();
}
void Physics2DServerWrapMT::thread_loop() {
server_thread=Thread::get_caller_ID();
OS::get_singleton()->make_rendering_thread();
physics_2d_server->init();
exit=false;
step_thread_up=true;
while(!exit) {
// flush commands one by one, until exit is requested
command_queue.wait_and_flush_one();
}
command_queue.flush_all(); // flush all
physics_2d_server->finish();
}
/* EVENT QUEUING */
void Physics2DServerWrapMT::step(float p_step) {
if (create_thread) {
command_queue.push( this, &Physics2DServerWrapMT::thread_step,p_step);
} else {
command_queue.flush_all(); //flush all pending from other threads
physics_2d_server->step(p_step);
}
}
void Physics2DServerWrapMT::sync() {
step_sem->wait();
physics_2d_server->sync();;
}
void Physics2DServerWrapMT::flush_queries(){
physics_2d_server->flush_queries();
}
void Physics2DServerWrapMT::end_sync() {
physics_2d_server->end_sync();;
}
void Physics2DServerWrapMT::init() {
if (create_thread) {
step_sem = Semaphore::create();
print_line("CREATING PHYSICS 2D THREAD");
//OS::get_singleton()->release_rendering_thread();
if (create_thread) {
thread = Thread::create( _thread_callback, this );
print_line("STARTING PHYISICS 2D THREAD");
}
while(!step_thread_up) {
OS::get_singleton()->delay_usec(1000);
}
print_line("DONE PHYSICS 2D THREAD");
} else {
physics_2d_server->init();
}
}
void Physics2DServerWrapMT::finish() {
if (thread) {
command_queue.push( this, &Physics2DServerWrapMT::thread_exit);
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();
}
if (step_sem)
memdelete(step_sem);
}
Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer* p_contained,bool p_create_thread) : command_queue(p_create_thread) {
physics_2d_server=p_contained;
create_thread=p_create_thread;
thread=NULL;
step_sem=NULL;
step_pending=0;
step_thread_up=false;
alloc_mutex=Mutex::create();
shape_pool_max_size=GLOBAL_DEF("core/thread_rid_pool_prealloc",20);
area_pool_max_size=GLOBAL_DEF("core/thread_rid_pool_prealloc",20);
body_pool_max_size=GLOBAL_DEF("core/thread_rid_pool_prealloc",20);
pin_joint_pool_max_size=GLOBAL_DEF("core/thread_rid_pool_prealloc",20);
groove_joint_pool_max_size=GLOBAL_DEF("core/thread_rid_pool_prealloc",20);
damped_spring_joint_pool_max_size=GLOBAL_DEF("core/thread_rid_pool_prealloc",20);
if (!p_create_thread) {
server_thread=Thread::get_caller_ID();
} else {
server_thread=0;
}
}
Physics2DServerWrapMT::~Physics2DServerWrapMT() {
memdelete(physics_2d_server);
memdelete(alloc_mutex);
//finish();
}

View file

@ -0,0 +1,295 @@
#ifndef PHYSICS2DSERVERWRAPMT_H
#define PHYSICS2DSERVERWRAPMT_H
#include "servers/physics_2d_server.h"
#include "command_queue_mt.h"
#include "os/thread.h"
#include "globals.h"
#ifdef DEBUG_SYNC
#define SYNC_DEBUG print_line("sync on: "+String(__FUNCTION__));
#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;
volatile bool exit;
Thread *thread;
volatile bool step_thread_up;
bool create_thread;
Semaphore *step_sem;
int step_pending;
void thread_step(float p_delta);
void thread_flush();
void thread_exit();
Mutex*alloc_mutex;
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;
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
FUNC1R(RID,shape_create,ShapeType);
FUNC2(shape_set_data,RID,const Variant& );
FUNC2(shape_set_custom_solver_bias,RID,real_t );
FUNC1RC(ShapeType,shape_get_type,RID );
FUNC1RC(Variant,shape_get_data,RID);
FUNC1RC(real_t,shape_get_custom_solver_bias,RID);
//these work well, but should be used from the main thread only
bool shape_collide(RID p_shape_A, const Matrix32& p_xform_A,const Vector2& p_motion_A,RID p_shape_B, const Matrix32& p_xform_B, const Vector2& p_motion_B,Vector2 *r_results,int p_result_max,int &r_result_count) {
ERR_FAIL_COND_V(server_thread!=Thread::get_caller_ID(),false);
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);
}
/* SPACE API */
FUNC0R(RID,space_create);
FUNC2(space_set_active,RID,bool);
FUNC1RC(bool,space_is_active,RID);
FUNC3(space_set_param,RID,SpaceParameter,real_t);
FUNC2RC(real_t,space_get_param,RID,SpaceParameter);
// this function only works on fixed process, errors and returns null otherwise
Physics2DDirectSpaceState* space_get_direct_state(RID p_space) {
ERR_FAIL_COND_V(server_thread!=Thread::get_caller_ID(),NULL);
return physics_2d_server->space_get_direct_state(p_space);
}
/* AREA API */
//FUNC0RID(area);
FUNC0R(RID,area_create);
FUNC2(area_set_space,RID,RID);
FUNC1RC(RID,area_get_space,RID);
FUNC2(area_set_space_override_mode,RID,AreaSpaceOverrideMode);
FUNC1RC(AreaSpaceOverrideMode,area_get_space_override_mode,RID);
FUNC3(area_add_shape,RID,RID,const Matrix32&);
FUNC3(area_set_shape,RID,int,RID);
FUNC3(area_set_shape_transform,RID,int,const Matrix32&);
FUNC1RC(int,area_get_shape_count,RID);
FUNC2RC(RID,area_get_shape,RID,int);
FUNC2RC(Matrix32,area_get_shape_transform,RID,int);
FUNC2(area_remove_shape,RID,int);
FUNC1(area_clear_shapes,RID);
FUNC2(area_attach_object_instance_ID,RID,ObjectID);
FUNC1RC(ObjectID,area_get_object_instance_ID,RID);
FUNC3(area_set_param,RID,AreaParameter,const Variant&);
FUNC2(area_set_transform,RID,const Matrix32&);
FUNC2RC(Variant,area_get_param,RID,AreaParameter);
FUNC1RC(Matrix32,area_get_transform,RID);
FUNC2(area_set_collision_mask,RID,uint32_t);
FUNC2(area_set_layer_mask,RID,uint32_t);
FUNC2(area_set_monitorable,RID,bool);
FUNC2(area_set_pickable,RID,bool);
FUNC3(area_set_monitor_callback,RID,Object*,const StringName&);
FUNC3(area_set_area_monitor_callback,RID,Object*,const StringName&);
/* BODY API */
//FUNC2RID(body,BodyMode,bool);
FUNC2R(RID,body_create,BodyMode,bool)
FUNC2(body_set_space,RID,RID);
FUNC1RC(RID,body_get_space,RID);
FUNC2(body_set_mode,RID,BodyMode);
FUNC1RC(BodyMode,body_get_mode,RID);
FUNC3(body_add_shape,RID,RID,const Matrix32&);
FUNC3(body_set_shape,RID,int,RID);
FUNC3(body_set_shape_transform,RID,int,const Matrix32&);
FUNC3(body_set_shape_metadata,RID,int,const Variant&);
FUNC1RC(int,body_get_shape_count,RID);
FUNC2RC(Matrix32,body_get_shape_transform,RID,int);
FUNC2RC(Variant,body_get_shape_metadata,RID,int);
FUNC2RC(RID,body_get_shape,RID,int);
FUNC3(body_set_shape_as_trigger,RID,int,bool);
FUNC2RC(bool,body_is_shape_set_as_trigger,RID,int);
FUNC2(body_remove_shape,RID,int);
FUNC1(body_clear_shapes,RID);
FUNC2(body_attach_object_instance_ID,RID,uint32_t);
FUNC1RC(uint32_t,body_get_object_instance_ID,RID);
FUNC2(body_set_continuous_collision_detection_mode,RID,CCDMode);
FUNC1RC(CCDMode,body_get_continuous_collision_detection_mode,RID);
FUNC2(body_set_layer_mask,RID,uint32_t);
FUNC1RC(uint32_t,body_get_layer_mask,RID);
FUNC2(body_set_collision_mask,RID,uint32_t);
FUNC1RC(uint32_t,body_get_collision_mask,RID);
FUNC3(body_set_param,RID,BodyParameter,float);
FUNC2RC(float,body_get_param,RID,BodyParameter);
FUNC3(body_set_state,RID,BodyState,const Variant&);
FUNC2RC(Variant,body_get_state,RID,BodyState);
FUNC2(body_set_applied_force,RID,const Vector2&);
FUNC1RC(Vector2,body_get_applied_force,RID);
FUNC2(body_set_applied_torque,RID,float);
FUNC1RC(float,body_get_applied_torque,RID);
FUNC3(body_apply_impulse,RID,const Vector2&,const Vector2&);
FUNC2(body_set_axis_velocity,RID,const Vector2&);
FUNC2(body_add_collision_exception,RID,RID);
FUNC2(body_remove_collision_exception,RID,RID);
FUNC2S(body_get_collision_exceptions,RID,List<RID>*);
FUNC2(body_set_max_contacts_reported,RID,int);
FUNC1RC(int,body_get_max_contacts_reported,RID);
FUNC2(body_set_one_way_collision_direction,RID,const Vector2&);
FUNC1RC(Vector2,body_get_one_way_collision_direction,RID);
FUNC2(body_set_one_way_collision_max_depth,RID,float);
FUNC1RC(float,body_get_one_way_collision_max_depth,RID);
FUNC2(body_set_contacts_reported_depth_treshold,RID,float);
FUNC1RC(float,body_get_contacts_reported_depth_treshold,RID);
FUNC2(body_set_omit_force_integration,RID,bool);
FUNC1RC(bool,body_is_omitting_force_integration,RID);
FUNC4(body_set_force_integration_callback,RID ,Object *,const StringName& ,const Variant& );
bool body_collide_shape(RID p_body, int p_body_shape,RID p_shape, const Matrix32& 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);
}
FUNC2(body_set_pickable,RID,bool);
bool body_test_motion(RID p_body,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL) {
ERR_FAIL_COND_V(server_thread!=Thread::get_caller_ID(),false);
return body_test_motion(p_body,p_motion,p_margin,r_result);
}
/* JOINT API */
FUNC3(joint_set_param,RID,JointParam,real_t);
FUNC2RC(real_t,joint_get_param,RID,JointParam);
///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);
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);
FUNC3(damped_string_joint_set_param,RID,DampedStringParam,real_t);
FUNC2RC(real_t,damped_string_joint_get_param,RID,DampedStringParam);
FUNC1RC(JointType,joint_get_type,RID);
/* MISC */
FUNC1(free,RID);
FUNC1(set_active,bool);
virtual void init();
virtual void step(float p_step);
virtual void sync();
virtual void end_sync();
virtual void flush_queries();
virtual void finish();
int get_process_info(ProcessInfo p_info) {
return physics_2d_server->get_process_info(p_info);
}
Physics2DServerWrapMT(Physics2DServer* p_contained,bool p_create_thread);
~Physics2DServerWrapMT();
template<class T>
static Physics2DServer* init_server() {
int tm = GLOBAL_DEF("physics_2d/thread_model",1);
if (tm==0) //single unsafe
return memnew( T );
else if (tm==1) //single saef
return memnew( Physics2DServerWrapMT( memnew( T ), false ));
else //single unsafe
return memnew( Physics2DServerWrapMT( memnew( T ), true ));
}
#undef ServerNameWrapMT
#undef ServerName
#undef server_name
};
#ifdef DEBUG_SYNC
#undef DEBUG_SYNC
#endif
#undef SYNC_DEBUG
#endif // PHYSICS2DSERVERWRAPMT_H

View file

@ -405,10 +405,10 @@ public:
virtual CCDMode body_get_continuous_collision_detection_mode(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 uint32_t body_get_layer_mask(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;
// common body variables
enum BodyParameter {
@ -539,6 +539,7 @@ public:
virtual void step(float p_step)=0;
virtual void sync()=0;
virtual void flush_queries()=0;
virtual void end_sync()=0;
virtual void finish()=0;
enum ProcessInfo {

View file

@ -0,0 +1,700 @@
#define FUNC0R(m_r,m_type)\
virtual m_r m_type() { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type();\
}\
}
#define FUNCRID(m_type)\
int m_type##allocn() {\
for(int i=0;i<m_type##_pool_max_size;i++) {\
m_type##_id_pool.push_back( server_name->m_type##_create() );\
}\
return 0;\
}\
void m_type##_free_cached_ids() {\
while (m_type##_id_pool.size()) {\
free(m_type##_id_pool.front()->get());\
m_type##_id_pool.pop_front();\
}\
}\
virtual RID m_type##_create() { \
if (Thread::get_caller_ID()!=server_thread) {\
RID rid;\
alloc_mutex->lock();\
if (m_type##_id_pool.size()==0) {\
int ret;\
command_queue.push_and_ret( this, &ServerNameWrapMT::m_type##allocn,&ret);\
}\
rid=m_type##_id_pool.front()->get();\
m_type##_id_pool.pop_front();\
alloc_mutex->unlock();\
return rid;\
} else {\
return server_name->m_type##_create();\
}\
}
#define FUNC1RID(m_type,m_arg1)\
int m_type##allocn() {\
for(int i=0;i<m_type##_pool_max_size;i++) {\
m_type##_id_pool.push_back( server_name->m_type##_create() );\
}\
return 0;\
}\
void m_type##_free_cached_ids() {\
while (m_type##_id_pool.size()) {\
free(m_type##_id_pool.front()->get());\
m_type##_id_pool.pop_front();\
}\
}\
virtual RID m_type##_create(m_arg1 p1) { \
if (Thread::get_caller_ID()!=server_thread) {\
RID rid;\
alloc_mutex->lock();\
if (m_type##_id_pool.size()==0) {\
int ret;\
command_queue.push_and_ret( this, &ServerNameWrapMT::m_type##allocn,p1,&ret);\
}\
rid=m_type##_id_pool.front()->get();\
m_type##_id_pool.pop_front();\
alloc_mutex->unlock();\
return rid;\
} else {\
return server_name->m_type##_create(p1);\
}\
}
#define FUNC2RID(m_type,m_arg1,m_arg2)\
int m_type##allocn() {\
for(int i=0;i<m_type##_pool_max_size;i++) {\
m_type##_id_pool.push_back( server_name->m_type##_create() );\
}\
return 0;\
}\
void m_type##_free_cached_ids() {\
while (m_type##_id_pool.size()) {\
free(m_type##_id_pool.front()->get());\
m_type##_id_pool.pop_front();\
}\
}\
virtual RID m_type##_create(m_arg1 p1,m_arg2 p2) { \
if (Thread::get_caller_ID()!=server_thread) {\
RID rid;\
alloc_mutex->lock();\
if (m_type##_id_pool.size()==0) {\
int ret;\
command_queue.push_and_ret( this, &ServerNameWrapMT::m_type##allocn,p1,p2,&ret);\
}\
rid=m_type##_id_pool.front()->get();\
m_type##_id_pool.pop_front();\
alloc_mutex->unlock();\
return rid;\
} else {\
return server_name->m_type##_create(p1,p2);\
}\
}
#define FUNC3RID(m_type,m_arg1,m_arg2,m_arg3)\
int m_type##allocn() {\
for(int i=0;i<m_type##_pool_max_size;i++) {\
m_type##_id_pool.push_back( server_name->m_type##_create() );\
}\
return 0;\
}\
void m_type##_free_cached_ids() {\
while (m_type##_id_pool.size()) {\
free(m_type##_id_pool.front()->get());\
m_type##_id_pool.pop_front();\
}\
}\
virtual RID m_type##_create(m_arg1 p1,m_arg2 p2,m_arg3 p3) { \
if (Thread::get_caller_ID()!=server_thread) {\
RID rid;\
alloc_mutex->lock();\
if (m_type##_id_pool.size()==0) {\
int ret;\
command_queue.push_and_ret( this, &ServerNameWrapMT::m_type##allocn,p1,p2,p3,&ret);\
}\
rid=m_type##_id_pool.front()->get();\
m_type##_id_pool.pop_front();\
alloc_mutex->unlock();\
return rid;\
} else {\
return server_name->m_type##_create(p1,p2,p3);\
}\
}
#define FUNC4RID(m_type,m_arg1,m_arg2,m_arg3,m_arg4)\
int m_type##allocn() {\
for(int i=0;i<m_type##_pool_max_size;i++) {\
m_type##_id_pool.push_back( server_name->m_type##_create() );\
}\
return 0;\
}\
void m_type##_free_cached_ids() {\
while (m_type##_id_pool.size()) {\
free(m_type##_id_pool.front()->get());\
m_type##_id_pool.pop_front();\
}\
}\
virtual RID m_type##_create(m_arg1 p1,m_arg2 p2,m_arg3 p3,m_arg4 p4) { \
if (Thread::get_caller_ID()!=server_thread) {\
RID rid;\
alloc_mutex->lock();\
if (m_type##_id_pool.size()==0) {\
int ret;\
command_queue.push_and_ret( this, &ServerNameWrapMT::m_type##allocn,p1,p2,p3,p4,&ret);\
}\
rid=m_type##_id_pool.front()->get();\
m_type##_id_pool.pop_front();\
alloc_mutex->unlock();\
return rid;\
} else {\
return server_name->m_type##_create(p1,p2,p3,p4);\
}\
}
#define FUNC5RID(m_type,m_arg1,m_arg2,m_arg3,m_arg4,m_arg5)\
int m_type##allocn() {\
for(int i=0;i<m_type##_pool_max_size;i++) {\
m_type##_id_pool.push_back( server_name->m_type##_create() );\
}\
return 0;\
}\
void m_type##_free_cached_ids() {\
while (m_type##_id_pool.size()) {\
free(m_type##_id_pool.front()->get());\
m_type##_id_pool.pop_front();\
}\
}\
virtual RID m_type##_create(m_arg1 p1,m_arg2 p2,m_arg3 p3,m_arg4 p4,m_arg5 p5) { \
if (Thread::get_caller_ID()!=server_thread) {\
RID rid;\
alloc_mutex->lock();\
if (m_type##_id_pool.size()==0) {\
int ret;\
command_queue.push_and_ret( this, &ServerNameWrapMT::m_type##allocn,p1,p2,p3,p4,p5,&ret);\
}\
rid=m_type##_id_pool.front()->get();\
m_type##_id_pool.pop_front();\
alloc_mutex->unlock();\
return rid;\
} else {\
return server_name->m_type##_create(p1,p2,p3,p4,p5);\
}\
}
#define FUNC0RC(m_r,m_type)\
virtual m_r m_type() const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type();\
}\
}
#define FUNC0(m_type)\
virtual void m_type() { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type);\
} else {\
server_name->m_type();\
}\
}
#define FUNC0C(m_type)\
virtual void m_type() const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type);\
} else {\
server_name->m_type();\
}\
}
#define FUNC0S(m_type)\
virtual void m_type() { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type);\
} else {\
server_name->m_type();\
}\
}
#define FUNC0SC(m_type)\
virtual void m_type() const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type);\
} else {\
server_name->m_type();\
}\
}
///////////////////////////////////////////////
#define FUNC1R(m_r,m_type,m_arg1)\
virtual m_r m_type(m_arg1 p1) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type(p1);\
}\
}
#define FUNC1RC(m_r,m_type,m_arg1)\
virtual m_r m_type(m_arg1 p1) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type(p1);\
}\
}
#define FUNC1S(m_type,m_arg1)\
virtual void m_type(m_arg1 p1) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1);\
} else {\
server_name->m_type(p1);\
}\
}
#define FUNC1SC(m_type,m_arg1)\
virtual void m_type(m_arg1 p1) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1);\
} else {\
server_name->m_type(p1);\
}\
}
#define FUNC1(m_type,m_arg1)\
virtual void m_type(m_arg1 p1) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1);\
} else {\
server_name->m_type(p1);\
}\
}
#define FUNC1C(m_type,m_arg1)\
virtual void m_type(m_arg1 p1) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1);\
} else {\
server_name->m_type(p1);\
}\
}
#define FUNC2R(m_r,m_type,m_arg1, m_arg2)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type(p1, p2);\
}\
}
#define FUNC2RC(m_r,m_type,m_arg1, m_arg2)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type(p1, p2);\
}\
}
#define FUNC2S(m_type,m_arg1, m_arg2)\
virtual void m_type(m_arg1 p1, m_arg2 p2) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2);\
} else {\
server_name->m_type(p1, p2);\
}\
}
#define FUNC2SC(m_type,m_arg1, m_arg2)\
virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2);\
} else {\
server_name->m_type(p1, p2);\
}\
}
#define FUNC2(m_type,m_arg1, m_arg2)\
virtual void m_type(m_arg1 p1, m_arg2 p2) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1, p2);\
} else {\
server_name->m_type(p1, p2);\
}\
}
#define FUNC2C(m_type,m_arg1, m_arg2)\
virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1, p2);\
} else {\
server_name->m_type(p1, p2);\
}\
}
#define FUNC3R(m_r,m_type,m_arg1, m_arg2, m_arg3)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type(p1, p2, p3);\
}\
}
#define FUNC3RC(m_r,m_type,m_arg1, m_arg2, m_arg3)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3,&ret);\
return ret;\
} else {\
return server_name->m_type(p1, p2, p3);\
}\
}
#define FUNC3S(m_type,m_arg1, m_arg2, m_arg3)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3);\
} else {\
server_name->m_type(p1, p2, p3);\
}\
}
#define FUNC3SC(m_type,m_arg1, m_arg2, m_arg3)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3);\
} else {\
server_name->m_type(p1, p2, p3);\
}\
}
#define FUNC3(m_type,m_arg1, m_arg2, m_arg3)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1, p2, p3);\
} else {\
server_name->m_type(p1, p2, p3);\
}\
}
#define FUNC3C(m_type,m_arg1, m_arg2, m_arg3)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1, p2, p3);\
} else {\
server_name->m_type(p1, p2, p3);\
}\
}
#define FUNC4R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type(p1, p2, p3, p4);\
}\
}
#define FUNC4RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type(p1, p2, p3, p4);\
}\
}
#define FUNC4S(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4);\
} else {\
server_name->m_type(p1, p2, p3, p4);\
}\
}
#define FUNC4SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4);\
} else {\
server_name->m_type(p1, p2, p3, p4);\
}\
}
#define FUNC4(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4);\
} else {\
server_name->m_type(p1, p2, p3, p4);\
}\
}
#define FUNC4C(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4);\
} else {\
server_name->m_type(p1, p2, p3, p4);\
}\
}
#define FUNC5R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4, p5,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type(p1, p2, p3, p4, p5);\
}\
}
#define FUNC5RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4, p5,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type(p1, p2, p3, p4, p5);\
}\
}
#define FUNC5S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4, p5);\
} else {\
server_name->m_type(p1, p2, p3, p4, p5);\
}\
}
#define FUNC5SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4, p5);\
} else {\
server_name->m_type(p1, p2, p3, p4, p5);\
}\
}
#define FUNC5(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4, p5);\
} else {\
server_name->m_type(p1, p2, p3, p4, p5);\
}\
}
#define FUNC5C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4, p5);\
} else {\
server_name->m_type(p1, p2, p3, p4, p5);\
}\
}
#define FUNC6R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type(p1, p2, p3, p4, p5, p6);\
}\
}
#define FUNC6RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6,&ret);\
return ret;\
} else {\
return server_name->m_type(p1, p2, p3, p4, p5, p6);\
}\
}
#define FUNC6S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6);\
} else {\
server_name->m_type(p1, p2, p3, p4, p5, p6);\
}\
}
#define FUNC6SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6);\
} else {\
server_name->m_type(p1, p2, p3, p4, p5, p6);\
}\
}
#define FUNC6(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6);\
} else {\
server_name->m_type(p1, p2, p3, p4, p5, p6);\
}\
}
#define FUNC6C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6);\
} else {\
server_name->m_type(p1, p2, p3, p4, p5, p6);\
}\
}
#define FUNC7R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6, p7,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type(p1, p2, p3, p4, p5, p6, p7);\
}\
}
#define FUNC7RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6, p7,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return server_name->m_type(p1, p2, p3, p4, p5, p6, p7);\
}\
}
#define FUNC7S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6, p7);\
} else {\
server_name->m_type(p1, p2, p3, p4, p5, p6, p7);\
}\
}
#define FUNC7SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6, p7);\
} else {\
server_name->m_type(p1, p2, p3, p4, p5, p6, p7);\
}\
}
#define FUNC7(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6, p7);\
} else {\
server_name->m_type(p1, p2, p3, p4, p5, p6, p7);\
}\
}
#define FUNC7C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( server_name, &ServerName::m_type,p1, p2, p3, p4, p5, p6, p7);\
} else {\
server_name->m_type(p1, p2, p3, p4, p5, p6, p7);\
}\
}

View file

@ -187,8 +187,8 @@ VisualServerWrapMT::VisualServerWrapMT(VisualServer* p_contained,bool p_create_t
draw_pending=0;
draw_thread_up=false;
alloc_mutex=Mutex::create();
texture_pool_max_size=GLOBAL_DEF("render/thread_textures_prealloc",20);
mesh_pool_max_size=GLOBAL_DEF("render/thread_meshes_prealloc",20);
texture_pool_max_size=GLOBAL_DEF("render/thread_textures_prealloc",5);
mesh_pool_max_size=GLOBAL_DEF("core/rid_pool_prealloc",20);
if (!p_create_thread) {
server_thread=Thread::get_caller_ID();
} else {

View file

@ -79,554 +79,10 @@ class VisualServerWrapMT : public VisualServer {
public:
#define FUNC0R(m_r,m_type)\
virtual m_r m_type() { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type();\
}\
}
#define FUNCRID(m_type)\
int m_type##allocn() {\
for(int i=0;i<m_type##_pool_max_size;i++) {\
m_type##_id_pool.push_back( visual_server->m_type##_create() );\
}\
return 0;\
}\
void m_type##_free_cached_ids() {\
while (m_type##_id_pool.size()) {\
free(m_type##_id_pool.front()->get());\
m_type##_id_pool.pop_front();\
}\
}\
virtual RID m_type##_create() { \
if (Thread::get_caller_ID()!=server_thread) {\
RID rid;\
alloc_mutex->lock();\
if (m_type##_id_pool.size()==0) {\
int ret;\
command_queue.push_and_ret( this, &VisualServerWrapMT::m_type##allocn,&ret);\
}\
rid=m_type##_id_pool.front()->get();\
m_type##_id_pool.pop_front();\
alloc_mutex->unlock();\
return rid;\
} else {\
return visual_server->m_type##_create();\
}\
}
#define FUNC0RC(m_r,m_type)\
virtual m_r m_type() const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type();\
}\
}
#define FUNC0(m_type)\
virtual void m_type() { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type);\
} else {\
visual_server->m_type();\
}\
}
#define FUNC0C(m_type)\
virtual void m_type() const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type);\
} else {\
visual_server->m_type();\
}\
}
#define FUNC0S(m_type)\
virtual void m_type() { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type);\
} else {\
visual_server->m_type();\
}\
}
#define FUNC0SC(m_type)\
virtual void m_type() const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type);\
} else {\
visual_server->m_type();\
}\
}
///////////////////////////////////////////////
#define FUNC1R(m_r,m_type,m_arg1)\
virtual m_r m_type(m_arg1 p1) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type(p1);\
}\
}
#define FUNC1RC(m_r,m_type,m_arg1)\
virtual m_r m_type(m_arg1 p1) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type(p1);\
}\
}
#define FUNC1S(m_type,m_arg1)\
virtual void m_type(m_arg1 p1) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1);\
} else {\
visual_server->m_type(p1);\
}\
}
#define FUNC1SC(m_type,m_arg1)\
virtual void m_type(m_arg1 p1) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1);\
} else {\
visual_server->m_type(p1);\
}\
}
#define FUNC1(m_type,m_arg1)\
virtual void m_type(m_arg1 p1) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1);\
} else {\
visual_server->m_type(p1);\
}\
}
#define FUNC1C(m_type,m_arg1)\
virtual void m_type(m_arg1 p1) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1);\
} else {\
visual_server->m_type(p1);\
}\
}
#define FUNC2R(m_r,m_type,m_arg1, m_arg2)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type(p1, p2);\
}\
}
#define FUNC2RC(m_r,m_type,m_arg1, m_arg2)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type(p1, p2);\
}\
}
#define FUNC2S(m_type,m_arg1, m_arg2)\
virtual void m_type(m_arg1 p1, m_arg2 p2) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2);\
} else {\
visual_server->m_type(p1, p2);\
}\
}
#define FUNC2SC(m_type,m_arg1, m_arg2)\
virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2);\
} else {\
visual_server->m_type(p1, p2);\
}\
}
#define FUNC2(m_type,m_arg1, m_arg2)\
virtual void m_type(m_arg1 p1, m_arg2 p2) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1, p2);\
} else {\
visual_server->m_type(p1, p2);\
}\
}
#define FUNC2C(m_type,m_arg1, m_arg2)\
virtual void m_type(m_arg1 p1, m_arg2 p2) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1, p2);\
} else {\
visual_server->m_type(p1, p2);\
}\
}
#define FUNC3R(m_r,m_type,m_arg1, m_arg2, m_arg3)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type(p1, p2, p3);\
}\
}
#define FUNC3RC(m_r,m_type,m_arg1, m_arg2, m_arg3)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3,&ret);\
return ret;\
} else {\
return visual_server->m_type(p1, p2, p3);\
}\
}
#define FUNC3S(m_type,m_arg1, m_arg2, m_arg3)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3);\
} else {\
visual_server->m_type(p1, p2, p3);\
}\
}
#define FUNC3SC(m_type,m_arg1, m_arg2, m_arg3)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3);\
} else {\
visual_server->m_type(p1, p2, p3);\
}\
}
#define FUNC3(m_type,m_arg1, m_arg2, m_arg3)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3);\
} else {\
visual_server->m_type(p1, p2, p3);\
}\
}
#define FUNC3C(m_type,m_arg1, m_arg2, m_arg3)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3);\
} else {\
visual_server->m_type(p1, p2, p3);\
}\
}
#define FUNC4R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type(p1, p2, p3, p4);\
}\
}
#define FUNC4RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type(p1, p2, p3, p4);\
}\
}
#define FUNC4S(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4);\
} else {\
visual_server->m_type(p1, p2, p3, p4);\
}\
}
#define FUNC4SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4);\
} else {\
visual_server->m_type(p1, p2, p3, p4);\
}\
}
#define FUNC4(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4);\
} else {\
visual_server->m_type(p1, p2, p3, p4);\
}\
}
#define FUNC4C(m_type,m_arg1, m_arg2, m_arg3, m_arg4)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4);\
} else {\
visual_server->m_type(p1, p2, p3, p4);\
}\
}
#define FUNC5R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type(p1, p2, p3, p4, p5);\
}\
}
#define FUNC5RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type(p1, p2, p3, p4, p5);\
}\
}
#define FUNC5S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5);\
} else {\
visual_server->m_type(p1, p2, p3, p4, p5);\
}\
}
#define FUNC5SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5);\
} else {\
visual_server->m_type(p1, p2, p3, p4, p5);\
}\
}
#define FUNC5(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5);\
} else {\
visual_server->m_type(p1, p2, p3, p4, p5);\
}\
}
#define FUNC5C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5);\
} else {\
visual_server->m_type(p1, p2, p3, p4, p5);\
}\
}
#define FUNC6R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type(p1, p2, p3, p4, p5, p6);\
}\
}
#define FUNC6RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6,&ret);\
return ret;\
} else {\
return visual_server->m_type(p1, p2, p3, p4, p5, p6);\
}\
}
#define FUNC6S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6);\
} else {\
visual_server->m_type(p1, p2, p3, p4, p5, p6);\
}\
}
#define FUNC6SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6);\
} else {\
visual_server->m_type(p1, p2, p3, p4, p5, p6);\
}\
}
#define FUNC6(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6);\
} else {\
visual_server->m_type(p1, p2, p3, p4, p5, p6);\
}\
}
#define FUNC6C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6);\
} else {\
visual_server->m_type(p1, p2, p3, p4, p5, p6);\
}\
}
#define FUNC7R(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
}\
}
#define FUNC7RC(m_r,m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
virtual m_r m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
if (Thread::get_caller_ID()!=server_thread) {\
m_r ret;\
command_queue.push_and_ret( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7,&ret);\
SYNC_DEBUG\
return ret;\
} else {\
return visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
}\
}
#define FUNC7S(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7);\
} else {\
visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
}\
}
#define FUNC7SC(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push_and_sync( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7);\
} else {\
visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
}\
}
#define FUNC7(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7);\
} else {\
visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
}\
}
#define FUNC7C(m_type,m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7)\
virtual void m_type(m_arg1 p1, m_arg2 p2, m_arg3 p3, m_arg4 p4, m_arg5 p5, m_arg6 p6, m_arg7 p7) const { \
if (Thread::get_caller_ID()!=server_thread) {\
command_queue.push( visual_server, &VisualServer::m_type,p1, p2, p3, p4, p5, p6, p7);\
} else {\
visual_server->m_type(p1, p2, p3, p4, p5, p6, p7);\
}\
}
#define ServerName VisualServer
#define ServerNameWrapMT VisualServerWrapMT
#define server_name visual_server
#include "servers/server_wrap_mt_common.h"
//FUNC0R(RID,texture_create);
FUNCRID(texture);
@ -1242,7 +698,15 @@ public:
VisualServerWrapMT(VisualServer* p_contained,bool p_create_thread);
~VisualServerWrapMT();
#undef ServerName
#undef ServerNameWrapMT
#undef server_name
};
#ifdef DEBUG_SYNC
#undef DEBUG_SYNC
#endif
#undef SYNC_DEBUG
#endif

View file

@ -1,10 +1,10 @@
#include "core/object.h"
#include "core/reference.h"
class FileAccess;
class PCKPacker : public Object {
class PCKPacker : public Reference {
OBJ_TYPE(PCKPacker, Object);
OBJ_TYPE(PCKPacker, Reference);
FileAccess* file;
int alignment;