Added delta timestep to 2d simulation
This commit is contained in:
@@ -919,7 +919,8 @@ int main(int argc, char * argv[])
|
|||||||
bool clean_after_build = false;
|
bool clean_after_build = false;
|
||||||
|
|
||||||
//DEBUG START
|
//DEBUG START
|
||||||
rc_filename = "/home/n00b/projects/bu/constraint_demo/main.bas";
|
//rc_filename = "/home/n00b/projects/bu/constraint_demo/main.bas";
|
||||||
|
rc_filename = "/home/n00b/projects/rcbasic_alpha3/test_project/main.bas";
|
||||||
//DEBUG END
|
//DEBUG END
|
||||||
|
|
||||||
//enable_presets = true;
|
//enable_presets = true;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,33 +1,59 @@
|
|||||||
10
|
9
|
||||||
|
6
|
||||||
|
0
|
||||||
|
18446744073709551581
|
||||||
|
0
|
||||||
|
0
|
||||||
|
1
|
||||||
|
76
|
||||||
|
5
|
||||||
2
|
2
|
||||||
0
|
|
||||||
18446744073709551590
|
|
||||||
0
|
|
||||||
0
|
|
||||||
0
|
|
||||||
48
|
48
|
||||||
3
|
main.#FOR:0 6831 0
|
||||||
2
|
main.#NEXT:0 7045 0
|
||||||
22
|
main.#WHILE:0 9865 0
|
||||||
cam_control 0 1
|
ELSE:0->CONDITION:0 10064 0
|
||||||
ELSE:0->CONDITION:0 285 1
|
ELSE:0->CONDITION:1 10176 0
|
||||||
ELSE:0->CONDITION:1 517 1
|
ENDIF:0 10176 0
|
||||||
ENDIF:0 517 1
|
SELECT:0->CASE:0 10220 0
|
||||||
ELSE:1->CONDITION:0 758 1
|
ELSE:1->CONDITION:0 10504 0
|
||||||
ELSE:1->CONDITION:1 990 1
|
ELSE:1->CONDITION:1 10650 0
|
||||||
ENDIF:1 990 1
|
ENDIF:1 10650 0
|
||||||
ELSE:2->CONDITION:0 1412 1
|
ELSE:2->CONDITION:0 10805 0
|
||||||
ELSE:2->CONDITION:1 1825 1
|
ELSE:2->CONDITION:1 10951 0
|
||||||
ENDIF:2 1825 1
|
ENDIF:2 10951 0
|
||||||
ELSE:3->CONDITION:0 2066 1
|
ELSE:3->CONDITION:0 11079 0
|
||||||
ELSE:3->CONDITION:1 2298 1
|
ENDIF:3 11079 0
|
||||||
ENDIF:3 2298 1
|
ELSE:4->CONDITION:0 11207 0
|
||||||
ELSE:4->CONDITION:0 2942 1
|
ENDIF:4 11207 0
|
||||||
ELSE:4->CONDITION:1 3355 1
|
ELSE:5->CONDITION:0 11559 0
|
||||||
ENDIF:4 3355 1
|
ELSE:5->CONDITION:1 11791 0
|
||||||
main.#WHILE:0 4664 0
|
ENDIF:5 11791 0
|
||||||
main.#WEND:0 4802 0
|
ELSE:6->CONDITION:0 12032 0
|
||||||
main.#WHILE:1 4802 0
|
ELSE:6->CONDITION:1 12264 0
|
||||||
ELSE:5->CONDITION:0 5001 0
|
ENDIF:6 12264 0
|
||||||
ENDIF:5 5001 0
|
ELSE:7->CONDITION:0 12659 0
|
||||||
main.#WEND:1 5885 0
|
ELSE:7->CONDITION:1 13045 0
|
||||||
|
ENDIF:7 13045 0
|
||||||
|
ELSE:8->CONDITION:0 13286 0
|
||||||
|
ELSE:8->CONDITION:1 13518 0
|
||||||
|
ENDIF:8 13518 0
|
||||||
|
ELSE:9->CONDITION:0 14135 0
|
||||||
|
ELSE:9->CONDITION:1 14521 0
|
||||||
|
ENDIF:9 14521 0
|
||||||
|
ELSE:10->CONDITION:0 14744 0
|
||||||
|
ENDIF:10 14744 0
|
||||||
|
ELSE:11->CONDITION:0 14967 0
|
||||||
|
ENDIF:11 14967 0
|
||||||
|
ELSE:12->CONDITION:0 15190 0
|
||||||
|
ENDIF:12 15190 0
|
||||||
|
SELECT:0->CASE:1 15199 0
|
||||||
|
ELSE:13->CONDITION:0 15483 0
|
||||||
|
ELSE:13->CONDITION:1 15595 0
|
||||||
|
ENDIF:13 15595 0
|
||||||
|
ELSE:14->CONDITION:0 15750 0
|
||||||
|
ELSE:14->CONDITION:1 15862 0
|
||||||
|
ENDIF:14 15862 0
|
||||||
|
SELECT:0->CASE:2 15973 0
|
||||||
|
SELECT:0->END 15973 0
|
||||||
|
main.#WEND:0 16000 0
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
/home/n00b/projects/bu/constraint_demo/main.bas
|
/home/n00b/projects/rcbasic_alpha3/test_project/main.bas
|
||||||
|
|||||||
@@ -1,36 +1,66 @@
|
|||||||
N main.cam_control cam_canvas 12
|
N main w 12
|
||||||
N main.cam_control current_canvas 13
|
N main h 13
|
||||||
N main.cam_control.#IF:2 crx 14
|
N main canvas2 14
|
||||||
N main.cam_control.#IF:2 cry 15
|
N main canvas1 15
|
||||||
N main.cam_control.#IF:2 crz 16
|
N main yellow 16
|
||||||
N main.cam_control.#ELSE:2->CONDITION:0 crx 17
|
N main darkyellow 17
|
||||||
N main.cam_control.#ELSE:2->CONDITION:0 cry 18
|
N main magenta 18
|
||||||
N main.cam_control.#ELSE:2->CONDITION:0 crz 19
|
N main cyan 19
|
||||||
N main.cam_control.#IF:4 crx 20
|
N main red 20
|
||||||
N main.cam_control.#IF:4 cry 21
|
N main grey 21
|
||||||
N main.cam_control.#IF:4 crz 22
|
N main blue 22
|
||||||
N main.cam_control.#ELSE:4->CONDITION:0 crx 23
|
N main darkblue 23
|
||||||
N main.cam_control.#ELSE:4->CONDITION:0 cry 24
|
N main orange 24
|
||||||
N main.cam_control.#ELSE:4->CONDITION:0 crz 25
|
N main black 25
|
||||||
N main window_width 26
|
N main green 26
|
||||||
N main window_height 27
|
N main white 27
|
||||||
N main fullscreen 28
|
N main sprite_canvas 28
|
||||||
N main vsync 29
|
N main gz_img 29
|
||||||
N main scene_canvas 30
|
N main rc_img 30
|
||||||
N main ui_canvas 31
|
N main rc 31
|
||||||
N main ground 32
|
N main gz 32
|
||||||
N main ground_material 33
|
N main gz_x 33
|
||||||
N main ground2 34
|
N main gz_y 34
|
||||||
N main ground2_material 35
|
N main rc_x 35
|
||||||
N main sphere 36
|
N main rc_y 36
|
||||||
N main sphere_material 37
|
N main x 37
|
||||||
N main sphere_gx 38
|
N main y 38
|
||||||
N main sphere_gy 39
|
N main lforce 39
|
||||||
N main sphere_gz 40
|
S main fnt$ 3
|
||||||
N main ground_sphere_constraint 41
|
N main hud_font 40
|
||||||
N main t 42
|
AS main hud_txt$ 4
|
||||||
N main.#WHILE:1 sx 43
|
N main.#FOR:0 i 41
|
||||||
N main.#WHILE:1 sy 44
|
N main mesh1 42
|
||||||
N main.#WHILE:1 sz 45
|
N main actor1 43
|
||||||
N main.#WHILE:1 vx 46
|
N main actor1_texture 44
|
||||||
N main.#WHILE:1 vy 47
|
N main c 45
|
||||||
|
N main mat 46
|
||||||
|
N main a_mat 47
|
||||||
|
N main level 48
|
||||||
|
N main actor2 49
|
||||||
|
N main ax 50
|
||||||
|
N main ay 51
|
||||||
|
N main az 52
|
||||||
|
N main init 53
|
||||||
|
N main i 54
|
||||||
|
N main vx 55
|
||||||
|
N main vy 56
|
||||||
|
N main vz 57
|
||||||
|
N main mass 58
|
||||||
|
N main anim 59
|
||||||
|
N main num_loops 60
|
||||||
|
N main off_x 61
|
||||||
|
N main off_y 62
|
||||||
|
N main test_mode 63
|
||||||
|
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:7 crx 64
|
||||||
|
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:7 cry 65
|
||||||
|
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:7 crz 66
|
||||||
|
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:7->CONDITION:0 crx 67
|
||||||
|
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:7->CONDITION:0 cry 68
|
||||||
|
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:7->CONDITION:0 crz 69
|
||||||
|
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:9 crx 70
|
||||||
|
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:9 cry 71
|
||||||
|
N main.#WHILE:0.#SELECT:0->CASE:0.#IF:9 crz 72
|
||||||
|
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:9->CONDITION:0 crx 73
|
||||||
|
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:9->CONDITION:0 cry 74
|
||||||
|
N main.#WHILE:0.#SELECT:0->CASE:0.#ELSE:9->CONDITION:0 crz 75
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# depslib dependency file v1.0
|
# depslib dependency file v1.0
|
||||||
1733023376 source:/home/n00b/Projects/RCBASIC4/rcbasic_build/main.cpp
|
1733028438 source:/home/n00b/Projects/RCBASIC4/rcbasic_build/main.cpp
|
||||||
<iostream>
|
<iostream>
|
||||||
<stack>
|
<stack>
|
||||||
<vector>
|
<vector>
|
||||||
|
|||||||
@@ -4446,8 +4446,8 @@ int main(int argc, char * argv[])
|
|||||||
std::cin >> debug_opt;
|
std::cin >> debug_opt;
|
||||||
if(debug_opt.compare("a")==0)
|
if(debug_opt.compare("a")==0)
|
||||||
{
|
{
|
||||||
rc_intern_dirChange("/home/n00b/projects/bu/rcbasic_v400a5_linux/test_project_v4a5");
|
rc_intern_dirChange("/home/n00b/projects/rcbasic_alpha3/test_project");
|
||||||
rc_filename = "test.cbc";
|
rc_filename = "main.cbc";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -946,7 +946,8 @@ int rc_canvasOpen(int w, int h, int vx, int vy, int vw, int vh, int mode, int ca
|
|||||||
{
|
{
|
||||||
b2Vec2 gravity(0, 0);
|
b2Vec2 gravity(0, 0);
|
||||||
canvas.physics2D.world = new b2World(gravity);
|
canvas.physics2D.world = new b2World(gravity);
|
||||||
canvas.physics2D.timeStep = 1/60.0; //the length of time passed to simulate (seconds)
|
canvas.physics2D.timeStep = -1; //the length of time passed to simulate (seconds)
|
||||||
|
canvas.physics2D.time_stamp = SDL_GetTicks();
|
||||||
canvas.physics2D.velocityIterations = 8; //how strongly to correct velocity
|
canvas.physics2D.velocityIterations = 8; //how strongly to correct velocity
|
||||||
canvas.physics2D.positionIterations = 3; //how strongly to correct position
|
canvas.physics2D.positionIterations = 3; //how strongly to correct position
|
||||||
canvas.physics2D.enabled = true;
|
canvas.physics2D.enabled = true;
|
||||||
@@ -3056,7 +3057,9 @@ void rc_preUpdate()
|
|||||||
if(rc_canvas[i].type != RC_CANVAS_TYPE_SPRITE)
|
if(rc_canvas[i].type != RC_CANVAS_TYPE_SPRITE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float step = rc_canvas[i].physics2D.timeStep;
|
Uint32 delta_time = SDL_GetTicks() - rc_canvas[i].physics2D.time_stamp;
|
||||||
|
rc_canvas[i].physics2D.time_stamp = SDL_GetTicks();
|
||||||
|
float step = rc_canvas[i].physics2D.timeStep < 0 ? (delta_time*0.001f) : rc_canvas[i].physics2D.timeStep;
|
||||||
int32 velocityIterations = rc_canvas[i].physics2D.velocityIterations;
|
int32 velocityIterations = rc_canvas[i].physics2D.velocityIterations;
|
||||||
int32 positionIterations = rc_canvas[i].physics2D.positionIterations;
|
int32 positionIterations = rc_canvas[i].physics2D.positionIterations;
|
||||||
|
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ struct rc_physicsWorld2D_obj
|
|||||||
b2World* world;
|
b2World* world;
|
||||||
|
|
||||||
rc_contactListener_obj* contact_listener;
|
rc_contactListener_obj* contact_listener;
|
||||||
float time_stamp;
|
Uint32 time_stamp;
|
||||||
float timeStep = 1/60.0; //the length of time passed to simulate (seconds)
|
float timeStep = 1/60.0; //the length of time passed to simulate (seconds)
|
||||||
int velocityIterations = 8; //how strongly to correct velocity
|
int velocityIterations = 8; //how strongly to correct velocity
|
||||||
int positionIterations = 3; //how strongly to correct position
|
int positionIterations = 3; //how strongly to correct position
|
||||||
|
|||||||
@@ -804,7 +804,9 @@ bool rc_spriteIsVisible(int spr_id)
|
|||||||
//This function is called on each canvas on update
|
//This function is called on each canvas on update
|
||||||
void drawSprites(int canvas_id)
|
void drawSprites(int canvas_id)
|
||||||
{
|
{
|
||||||
float step = rc_canvas[canvas_id].physics2D.timeStep;
|
Uint32 delta_time = SDL_GetTicks() - rc_canvas[canvas_id].physics2D.time_stamp;
|
||||||
|
rc_canvas[canvas_id].physics2D.time_stamp = SDL_GetTicks();
|
||||||
|
float step = rc_canvas[canvas_id].physics2D.timeStep < 0 ? (delta_time*0.001f) : rc_canvas[canvas_id].physics2D.timeStep;
|
||||||
int32 velocityIterations = rc_canvas[canvas_id].physics2D.velocityIterations;
|
int32 velocityIterations = rc_canvas[canvas_id].physics2D.velocityIterations;
|
||||||
int32 positionIterations = rc_canvas[canvas_id].physics2D.positionIterations;
|
int32 positionIterations = rc_canvas[canvas_id].physics2D.positionIterations;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# depslib dependency file v1.0
|
# depslib dependency file v1.0
|
||||||
1733023264 source:/home/n00b/Projects/RCBASIC4/rcbasic_runtime/main.cpp
|
1733028476 source:/home/n00b/Projects/RCBASIC4/rcbasic_runtime/main.cpp
|
||||||
"rc_os_defines.h"
|
"rc_os_defines.h"
|
||||||
<emscripten.h>
|
<emscripten.h>
|
||||||
<sys/param.h>
|
<sys/param.h>
|
||||||
@@ -1247,7 +1247,7 @@
|
|||||||
1727545973 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/RealisticWater.h
|
1727545973 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/RealisticWater.h
|
||||||
<irrlicht.h>
|
<irrlicht.h>
|
||||||
|
|
||||||
1733027113 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx.h
|
1733028476 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx.h
|
||||||
"SDL.h"
|
"SDL.h"
|
||||||
<SDL2/SDL.h>
|
<SDL2/SDL.h>
|
||||||
<irrlicht.h>
|
<irrlicht.h>
|
||||||
@@ -1271,7 +1271,7 @@
|
|||||||
"rc_joints.h"
|
"rc_joints.h"
|
||||||
<irrtheora.h>
|
<irrtheora.h>
|
||||||
|
|
||||||
1733027113 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx_core.h
|
1733028476 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx_core.h
|
||||||
"SDL.h"
|
"SDL.h"
|
||||||
"btBulletDynamicsCommon.h"
|
"btBulletDynamicsCommon.h"
|
||||||
"BulletSoftBody/btSoftRigidDynamicsWorld.h"
|
"BulletSoftBody/btSoftRigidDynamicsWorld.h"
|
||||||
@@ -2487,7 +2487,7 @@
|
|||||||
<irrlicht.h>
|
<irrlicht.h>
|
||||||
<cmath>
|
<cmath>
|
||||||
|
|
||||||
1731722537 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_spritelib.h
|
1733028518 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_spritelib.h
|
||||||
"SDL.h"
|
"SDL.h"
|
||||||
<SDL2/SDL.h>
|
<SDL2/SDL.h>
|
||||||
"rc_sprite2D.h"
|
"rc_sprite2D.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user