summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/input_default.cpp28
-rw-r--r--main/input_default.h2
-rw-r--r--main/main.cpp77
-rw-r--r--main/performance.cpp2
-rw-r--r--main/tests/test_containers.cpp3
-rw-r--r--main/tests/test_gdscript.cpp2
-rw-r--r--main/tests/test_gui.cpp4
-rw-r--r--main/tests/test_math.cpp2
-rw-r--r--main/tests/test_physics.cpp4
-rw-r--r--main/tests/test_physics_2d.cpp20
-rw-r--r--main/tests/test_render.cpp6
-rw-r--r--main/tests/test_string.cpp2
12 files changed, 82 insertions, 70 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp
index c2c4e28854..a7d06dbdbe 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -158,10 +158,10 @@ bool InputDefault::is_action_just_pressed(const StringName& p_action) const {
if (!E)
return false;
- if (OS::get_singleton()->is_in_fixed_frame()) {
- return E->get().pressed && E->get().fixed_frame==OS::get_singleton()->get_fixed_frames();
+ if (Engine::get_singleton()->is_in_fixed_frame()) {
+ return E->get().pressed && E->get().fixed_frame==Engine::get_singleton()->get_fixed_frames();
} else {
- return E->get().pressed && E->get().idle_frame==OS::get_singleton()->get_idle_frames();
+ return E->get().pressed && E->get().idle_frame==Engine::get_singleton()->get_idle_frames();
}
}
@@ -171,10 +171,10 @@ bool InputDefault::is_action_just_released(const StringName& p_action) const{
if (!E)
return false;
- if (OS::get_singleton()->is_in_fixed_frame()) {
- return !E->get().pressed && E->get().fixed_frame==OS::get_singleton()->get_fixed_frames();
+ if (Engine::get_singleton()->is_in_fixed_frame()) {
+ return !E->get().pressed && E->get().fixed_frame==Engine::get_singleton()->get_fixed_frames();
} else {
- return !E->get().pressed && E->get().idle_frame==OS::get_singleton()->get_idle_frames();
+ return !E->get().pressed && E->get().idle_frame==Engine::get_singleton()->get_idle_frames();
}
}
@@ -313,7 +313,7 @@ void InputDefault::parse_input_event(const InputEvent& p_event) {
if (p_event.key.scancode==0)
break;
- // print_line(p_event);
+ //print_line(p_event);
if (p_event.key.pressed)
keys_pressed.insert(p_event.key.scancode);
@@ -385,8 +385,8 @@ void InputDefault::parse_input_event(const InputEvent& p_event) {
if(is_action_pressed(E->key()) != p_event.is_pressed()) {
Action action;
- action.fixed_frame=OS::get_singleton()->get_fixed_frames();
- action.idle_frame=OS::get_singleton()->get_idle_frames();
+ action.fixed_frame=Engine::get_singleton()->get_fixed_frames();
+ action.idle_frame=Engine::get_singleton()->get_idle_frames();
action.pressed=p_event.is_pressed();
action_state[E->key()]=action;
}
@@ -479,7 +479,7 @@ Point2 InputDefault::get_mouse_pos() const {
return mouse_pos;
}
-Point2 InputDefault::get_mouse_speed() const {
+Point2 InputDefault::get_last_mouse_speed() const {
return mouse_speed_track.speed;
}
@@ -504,8 +504,8 @@ void InputDefault::action_press(const StringName& p_action) {
Action action;
- action.fixed_frame=OS::get_singleton()->get_fixed_frames();
- action.idle_frame=OS::get_singleton()->get_idle_frames();
+ action.fixed_frame=Engine::get_singleton()->get_fixed_frames();
+ action.idle_frame=Engine::get_singleton()->get_idle_frames();
action.pressed=true;
action_state[p_action]=action;
@@ -516,8 +516,8 @@ void InputDefault::action_release(const StringName& p_action){
Action action;
- action.fixed_frame=OS::get_singleton()->get_fixed_frames();
- action.idle_frame=OS::get_singleton()->get_idle_frames();
+ action.fixed_frame=Engine::get_singleton()->get_fixed_frames();
+ action.idle_frame=Engine::get_singleton()->get_idle_frames();
action.pressed=false;
action_state[p_action]=action;
diff --git a/main/input_default.h b/main/input_default.h
index fe7e89d771..3e41c494c1 100644
--- a/main/input_default.h
+++ b/main/input_default.h
@@ -198,7 +198,7 @@ public:
virtual Vector3 get_gyroscope() const;
virtual Point2 get_mouse_pos() const;
- virtual Point2 get_mouse_speed() const;
+ virtual Point2 get_last_mouse_speed() const;
virtual int get_mouse_button_mask() const;
virtual void warp_mouse_pos(const Vector2& p_to);
diff --git a/main/main.cpp b/main/main.cpp
index 16adee4bf6..e535da3e28 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -79,6 +79,7 @@
#include "performance.h"
static GlobalConfig *globals=NULL;
+static Engine *engine=NULL;
static InputMap *input_map=NULL;
static bool _start_success=false;
static ScriptDebugger *script_debugger=NULL;
@@ -195,6 +196,9 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
RID_OwnerBase::init_rid();
OS::get_singleton()->initialize_core();
+
+ engine = memnew( Engine );
+
ClassDB::init();
MAIN_PRINT("Main: Initialize CORE");
@@ -235,7 +239,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
while (I) {
I->get()=unescape_cmdline(I->get().strip_escapes());
-// print_line("CMD: "+I->get());
+ //print_line("CMD: "+I->get());
I=I->next();
}
@@ -499,7 +503,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
if (I->next()) {
- OS::get_singleton()->set_time_scale(I->next()->get().to_double());
+ Engine::get_singleton()->set_time_scale(I->next()->get().to_double());
N=I->next()->next();
} else {
goto error;
@@ -707,7 +711,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
input_map->load_from_globals(); //keys for game
if (video_driver=="") // specified in engine.cfg
- video_driver=_GLOBAL_DEF("display/driver/name",Variant((const char*)OS::get_singleton()->get_video_driver_name(0)));
+ video_driver=GLOBAL_DEF("display/driver/name",Variant((const char*)OS::get_singleton()->get_video_driver_name(0)));
if (!force_res && use_custom_res && globals->has("display/window/width"))
video_mode.width=globals->get("display/window/width");
@@ -742,7 +746,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
use_vsync = GLOBAL_DEF("display/window/use_vsync", use_vsync);
GLOBAL_DEF("display/window/test_width",0);
GLOBAL_DEF("display/window/test_height",0);
- OS::get_singleton()->_pixel_snap=GLOBAL_DEF("rendering/2d/use_pixel_snap",false);
+ Engine::get_singleton()->_pixel_snap=GLOBAL_DEF("rendering/2d/use_pixel_snap",false);
OS::get_singleton()->_keep_screen_on=GLOBAL_DEF("display/energy_saving/keep_screen_on",true);
if (rtm==-1) {
rtm=GLOBAL_DEF("rendering/threads/thread_model",OS::RENDER_THREAD_SAFE);
@@ -819,8 +823,8 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
}
- OS::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/common/fixed_fps",60));
- OS::get_singleton()->set_target_fps(GLOBAL_DEF("debug/fps/force_fps",0));
+ Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/common/fixed_fps",60));
+ Engine::get_singleton()->set_target_fps(GLOBAL_DEF("debug/fps/force_fps",0));
GLOBAL_DEF("debug/stdout/print_fps", OS::get_singleton()->is_stdout_verbose());
@@ -831,7 +835,7 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
frame_delay=GLOBAL_DEF("application/frame_delay_msec",0);
}
- OS::get_singleton()->set_frame_delay(frame_delay);
+ Engine::get_singleton()->set_frame_delay(frame_delay);
message_queue = memnew( MessageQueue );
@@ -862,6 +866,8 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
memdelete( translation_server );
if (globals)
memdelete(globals);
+ if (engine)
+ memdelete(engine);
if (script_debugger)
memdelete(script_debugger);
if (packed_data)
@@ -873,10 +879,12 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas
// Note 1: *zip_packed_data live into *packed_data
// Note 2: PackedData::~PackedData destroy this.
-//#ifdef MINIZIP_ENABLED
-// if (zip_packed_data)
-// memdelete( zip_packed_data );
-//#endif
+/*
+#ifdef MINIZIP_ENABLED
+ if (zip_packed_data)
+ memdelete( zip_packed_data );
+#endif
+*/
unregister_core_driver_types();
unregister_core_types();
@@ -949,7 +957,7 @@ Error Main::setup2() {
VisualServer::get_singleton()->set_boot_image(boot_logo, boot_bg,boot_logo_scale);
#ifndef TOOLS_ENABLED
//no tools, so free the boot logo (no longer needed)
- // GlobalConfig::get_singleton()->set("application/boot_logo",Image());
+ //GlobalConfig::get_singleton()->set("application/boot_logo",Image());
#endif
} else {
@@ -1003,7 +1011,7 @@ Error Main::setup2() {
//print_line("use custom cursor");
Ref<Texture> cursor=ResourceLoader::load(GlobalConfig::get_singleton()->get("display/mouse_cursor/custom_image"));
if (cursor.is_valid()) {
- // print_line("loaded ok");
+ //print_line("loaded ok");
Vector2 hotspot = GlobalConfig::get_singleton()->get("display/mouse_cursor/custom_image_hotspot");
Input::get_singleton()->set_custom_mouse_cursor(cursor,hotspot);
}
@@ -1096,7 +1104,7 @@ bool Main::start() {
} else if (args[i]=="-script" || args[i]=="-s") {
script=args[i+1];
} else if (args[i]=="-level" || args[i]=="-l") {
- OS::get_singleton()->_custom_level=args[i+1];
+ Engine::get_singleton()->_custom_level=args[i+1];
} else if (args[i]=="-test") {
test=args[i+1];
} else if (args[i]=="-optimize") {
@@ -1579,11 +1587,12 @@ bool Main::iteration() {
uint64_t ticks_elapsed=ticks-last_ticks;
double step=(double)ticks_elapsed / 1000000.0;
- float frame_slice=1.0/OS::get_singleton()->get_iterations_per_second();
-
-// if (time_accum+step < frame_slice)
-// return false;
+ float frame_slice=1.0/Engine::get_singleton()->get_iterations_per_second();
+ /*
+ if (time_accum+step < frame_slice)
+ return false;
+ */
uint64_t fixed_process_ticks=0;
uint64_t idle_process_ticks=0;
@@ -1597,13 +1606,13 @@ bool Main::iteration() {
time_accum+=step;
- float time_scale = OS::get_singleton()->get_time_scale();
+ float time_scale = Engine::get_singleton()->get_time_scale();
bool exit=false;
int iters = 0;
- OS::get_singleton()->_in_fixed=true;
+ Engine::get_singleton()->_in_fixed=true;
while(time_accum>frame_slice) {
@@ -1629,16 +1638,18 @@ bool Main::iteration() {
time_accum-=frame_slice;
message_queue->flush();
- //if (AudioServer::get_singleton())
- // AudioServer::get_singleton()->update();
+ /*
+ if (AudioServer::get_singleton())
+ AudioServer::get_singleton()->update();
+ */
fixed_process_ticks=MAX(fixed_process_ticks,OS::get_singleton()->get_ticks_usec()-fixed_begin); // keep the largest one for reference
fixed_process_max=MAX(OS::get_singleton()->get_ticks_usec()-fixed_begin,fixed_process_max);
iters++;
- OS::get_singleton()->_fixed_frames++;
+ Engine::get_singleton()->_fixed_frames++;
}
- OS::get_singleton()->_in_fixed=false;
+ Engine::get_singleton()->_in_fixed=false;
uint64_t idle_begin = OS::get_singleton()->get_ticks_usec();
@@ -1658,11 +1669,11 @@ bool Main::iteration() {
if ((!force_redraw_requested) && OS::get_singleton()->is_in_low_processor_usage_mode()) {
if (VisualServer::get_singleton()->has_changed()) {
VisualServer::get_singleton()->draw(); // flush visual commands
- OS::get_singleton()->frames_drawn++;
+ Engine::get_singleton()->frames_drawn++;
}
} else {
VisualServer::get_singleton()->draw(); // flush visual commands
- OS::get_singleton()->frames_drawn++;
+ Engine::get_singleton()->frames_drawn++;
force_redraw_requested = false;
}
}
@@ -1686,9 +1697,9 @@ bool Main::iteration() {
}
- // x11_delay_usec(10000);
+ //x11_delay_usec(10000);
frames++;
- OS::get_singleton()->_idle_frames++;
+ Engine::get_singleton()->_idle_frames++;
if (frame>1000000) {
@@ -1696,7 +1707,7 @@ bool Main::iteration() {
print_line("FPS: "+itos(frames));
};
- OS::get_singleton()->_fps=frames;
+ Engine::get_singleton()->_fps=frames;
performance->set_process_time(USEC_TO_SEC(idle_process_max));
performance->set_fixed_process_time(USEC_TO_SEC(fixed_process_max));
idle_process_max=0;
@@ -1710,12 +1721,12 @@ bool Main::iteration() {
if (OS::get_singleton()->is_in_low_processor_usage_mode() || !OS::get_singleton()->can_draw())
OS::get_singleton()->delay_usec(16600); //apply some delay to force idle time (results in about 60 FPS max)
else {
- uint32_t frame_delay = OS::get_singleton()->get_frame_delay();
+ uint32_t frame_delay = Engine::get_singleton()->get_frame_delay();
if (frame_delay)
- OS::get_singleton()->delay_usec( OS::get_singleton()->get_frame_delay()*1000 );
+ OS::get_singleton()->delay_usec( Engine::get_singleton()->get_frame_delay()*1000 );
}
- int target_fps = OS::get_singleton()->get_target_fps();
+ int target_fps = Engine::get_singleton()->get_target_fps();
if (target_fps>0) {
uint64_t time_step = 1000000L/target_fps;
target_ticks += time_step;
@@ -1777,6 +1788,8 @@ void Main::cleanup() {
memdelete(path_remap);
if (globals)
memdelete(globals);
+ if (engine)
+ memdelete(engine);
diff --git a/main/performance.cpp b/main/performance.cpp
index 2ca73c6d4b..91df55a21c 100644
--- a/main/performance.cpp
+++ b/main/performance.cpp
@@ -118,7 +118,7 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
float Performance::get_monitor(Monitor p_monitor) const {
switch(p_monitor) {
- case TIME_FPS: return OS::get_singleton()->get_frames_per_second();
+ case TIME_FPS: return Engine::get_singleton()->get_frames_per_second();
case TIME_PROCESS: return _process_time;
case TIME_FIXED_PROCESS: return _fixed_process_time;
case MEMORY_STATIC: return Memory::get_mem_usage();
diff --git a/main/tests/test_containers.cpp b/main/tests/test_containers.cpp
index 4bc297d0ba..2711d107e4 100644
--- a/main/tests/test_containers.cpp
+++ b/main/tests/test_containers.cpp
@@ -55,7 +55,6 @@ MainLoop * test() {
{
-// static const int size = 16;
Image img;
img.create(default_mouse_cursor_xpm);
@@ -78,7 +77,7 @@ MainLoop * test() {
for (int i=0;i<1100;i++) {
int num=i;//(int)Math::random(0,1024);
- // print_line("inserting "+itos(num));
+ //print_line("inserting "+itos(num));
set.insert( num );
}
diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp
index 1ee27ec661..4f4e76d517 100644
--- a/main/tests/test_gdscript.cpp
+++ b/main/tests/test_gdscript.cpp
@@ -1026,7 +1026,7 @@ MainLoop* test(TestType p_test) {
} else if (p_test==TEST_BYTECODE) {
Vector<uint8_t> buf = GDTokenizerBuffer::parse_code_string(code);
- String dst = test.basename()+".gdc";
+ String dst = test.get_basename()+".gdc";
FileAccess *fw = FileAccess::open(dst,FileAccess::WRITE);
fw->store_buffer(buf.ptr(),buf.size());
memdelete(fw);
diff --git a/main/tests/test_gui.cpp b/main/tests/test_gui.cpp
index ab3df3b022..b0ebc20180 100644
--- a/main/tests/test_gui.cpp
+++ b/main/tests/test_gui.cpp
@@ -46,7 +46,7 @@
#include "scene/gui/tab_container.h"
#include "scene/gui/tree.h"
#include "scene/gui/rich_text_label.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "io/image_loader.h"
#include "print_string.h"
#include "scene/2d/sprite.h"
@@ -97,7 +97,7 @@ public:
Sprite *sp = memnew( Sprite );
sp->set_texture( vp->get_render_target_texture() );
-// sp->set_texture( ResourceLoader::load("res://ball.png") );
+ //sp->set_texture( ResourceLoader::load("res://ball.png") );
sp->set_pos(Point2(300,300));
get_root()->add_child(sp);
diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp
index f3d9ddba87..89513b81d9 100644
--- a/main/tests/test_math.cpp
+++ b/main/tests/test_math.cpp
@@ -596,7 +596,7 @@ MainLoop* test() {
{
- // print_line("NUM: "+itos(237641278346127));
+ //print_line("NUM: "+itos(237641278346127));
print_line("NUM: "+itos(-128));
return NULL;
diff --git a/main/tests/test_physics.cpp b/main/tests/test_physics.cpp
index ea5b1cae85..ea98da34ca 100644
--- a/main/tests/test_physics.cpp
+++ b/main/tests/test_physics.cpp
@@ -358,9 +358,9 @@ public:
gxf.basis.scale(Vector3(1.4,0.4,1.4));
gxf.origin=Vector3(-2,1,-2);
make_grid(5,5,2.5,1,gxf);
- // create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_STATIC,gxf);
+ //create_body(PhysicsServer::SHAPE_BOX,PhysicsServer::BODY_MODE_STATIC,gxf);
//create_static_plane( Plane( Vector3(0,1,0), -2) );
-// test_joint();
+ //test_joint();
test_fall();
//test_joint();
diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp
index 2074d532b1..8a6a8c78f9 100644
--- a/main/tests/test_physics_2d.cpp
+++ b/main/tests/test_physics_2d.cpp
@@ -218,8 +218,10 @@ class TestPhysics2DMainLoop : public MainLoop {
void _do_ray_query() {
-// Physics2DServer *ps = Physics2DServer::get_singleton();
- // ps->query_intersection_segment(ray_query,ray_from,ray_to);
+ /*
+ Physics2DServer *ps = Physics2DServer::get_singleton();
+ ps->query_intersection_segment(ray_query,ray_from,ray_to);
+ */
}
@@ -273,7 +275,7 @@ protected:
ps->body_set_continuous_collision_detection_mode(body,Physics2DServer::CCD_MODE_CAST_SHAPE);
ps->body_set_state(body,Physics2DServer::BODY_STATE_TRANSFORM,p_xform);
-// print_line("add body with xform: "+p_xform);
+ //print_line("add body with xform: "+p_xform);
RID sprite = vs->canvas_item_create();
vs->canvas_item_set_parent(sprite,canvas);
vs->canvas_item_set_transform(sprite,p_xform);
@@ -281,8 +283,8 @@ protected:
vs->canvas_item_add_texture_rect(sprite,Rect2(-imgsize/2.0,imgsize),body_shape_data[p_shape].image);
ps->body_set_force_integration_callback(body,this,"_body_moved",sprite);
-// RID q = ps->query_create(this,"_body_moved",sprite);
-// ps->query_body_state(q,body);
+ //RID q = ps->query_create(this,"_body_moved",sprite);
+ //ps->query_body_state(q,body);
return body;
}
@@ -409,10 +411,12 @@ public:
};
Physics2DServer::ShapeType type = types[i%4];
-// type=Physics2DServer::SHAPE_SEGMENT;
+ //type=Physics2DServer::SHAPE_SEGMENT;
_add_body(type,Transform2D(i*0.8,Point2(152+i*40,100-40*i)));
- //if (i==0)
- // ps->body_set_mode(b,Physics2DServer::BODY_MODE_STATIC);
+ /*
+ if (i==0)
+ ps->body_set_mode(b,Physics2DServer::BODY_MODE_STATIC);
+ */
}
//RID b= _add_body(Physics2DServer::SHAPE_CIRCLE,Transform2D(0,Point2(101,140)));
diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp
index 3049ba7d45..7380c1ff6a 100644
--- a/main/tests/test_render.cpp
+++ b/main/tests/test_render.cpp
@@ -192,7 +192,6 @@ public:
*/
RID lightaux;
- //*
lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
//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) );
@@ -203,17 +202,14 @@ public:
lla.set_look_at(Vector3(),Vector3(-0.000000,-0.836026,-0.548690),Vector3(0,1,0));
vs->instance_set_transform( light, lla );
- // */
- //*
lightaux = vs->light_create( VisualServer::LIGHT_OMNI );
-// vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) );
+ //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 );
vs->light_set_param( lightaux, VisualServer::LIGHT_PARAM_ENERGY, 8 );
//vs->light_set_shadow( lightaux, true );
//light = vs->instance_create( lightaux );
- // */
ofs=0;
quit=false;
diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp
index d99ad4476f..a4a8ceb072 100644
--- a/main/tests/test_string.cpp
+++ b/main/tests/test_string.cpp
@@ -252,7 +252,7 @@ bool test_13() {
/* how can i embed UTF in here? */
static const CharType ustr[] = { 0x304A , 0x360F, 0x3088, 0x3046, 0 };
-// static const wchar_t ustr[] = { 'P', 0xCE, 'p',0xD3, 0 };
+ //static const wchar_t ustr[] = { 'P', 0xCE, 'p',0xD3, 0 };
String s=ustr;
OS::get_singleton()->print("\tUnicode: %ls\n",ustr);