summaryrefslogtreecommitdiff
path: root/c2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c2.cpp')
-rw-r--r--c2.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/c2.cpp b/c2.cpp
index 58f3831..be27f60 100644
--- a/c2.cpp
+++ b/c2.cpp
@@ -3,6 +3,7 @@
#include "debugdraw.hpp"
#include "editor.hpp"
#include "model.hpp"
+#include "physics.hpp"
#include "scene.hpp"
#include "ui.hpp"
#include "video.hpp"
@@ -632,10 +633,11 @@ struct C2 : public App {
Asset_Arena assets;
Device* dev;
Shader* shader, * ui_shader;
+ Collider* box_col, * floor_col;
Texture* texture;
Texture* texture2;
Texture_Id default_texture;
- Entity_Id monkey, monkey2;
+ Entity_Id monkey, monkey2, box, floor;
Model_Scene scene;
Orbit_Cam camera;
Fullscreen_Quad quad;
@@ -736,12 +738,32 @@ struct C2 : public App {
(Model*)assets.load("monkey.mdl")
);
}
+ {
+ box_col = make_box(&asset_arena, v3f(1.0f, 1.0f, 1.0f));
+ floor_col = make_box(&asset_arena, v3f(10.0f, 0.1f, 10.0f));
+ box = world->create_entity();
+ auto [trans, rb] = world->add<Transform, Rigidbody>(box);
+ trans.mat = m4f::identity();
+ rb.init(box_col, v3f(0.0f, 5.0f, 0.0f), quat::identity(), 1.0f);
+ rb.add_force(v3f(0.4f, -1.0f, 0.0f), v3f(0.0f, 0.1f, 0.0f));
+
+ floor = world->create_entity();
+ auto [transf, rbf] = world->add<Transform, Rigidbody>(floor);
+ transf.mat = m4f::identity();
+ rbf.init(floor_col, v3f(0.0f), quat::identity(), 0.0f);
+ }
}
void on_update() override {
+ float phys_dt = dt;
+ Editor_Settings& es = editor_settings();
Arena frame_arena;
init_arena(&frame_arena, per_frame, per_frame_memory_size);
+ if (es.pause_physics)
+ phys_dt = 0.0f;
+ physics_update(*world, &frame_arena, phys_dt);
+
dev->begin_frame();
lr.begin(w, h);
@@ -930,6 +952,9 @@ struct C2 : public App {
editor_draw(lr);
+ if (es.debug_physics)
+ physics_debug(*world, lr);
+
ctx.debug_push("debug");
pb.begin_rp();
pb.rp_target(dev->get_backbuffer(), Clear_Mode::restore);