work on world storage
This commit is contained in:
parent
6b62b78595
commit
3f314c23c9
File diff suppressed because it is too large
Load Diff
@ -59,6 +59,7 @@ get_level_editor_camera :: () -> Camera {
|
|||||||
return camera;
|
return camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tick_level_editor_camera :: () {
|
tick_level_editor_camera :: () {
|
||||||
if console_open_ignore_input then return;
|
if console_open_ignore_input then return;
|
||||||
|
|
||||||
@ -199,16 +200,26 @@ draw_tacoma_tab :: (theme: *GR.Overall_Theme, total_r: GR.Rect) {
|
|||||||
|
|
||||||
#scope_export
|
#scope_export
|
||||||
|
|
||||||
|
add_trile :: (name: string, x: float, y: float, z: float) {
|
||||||
|
for world.positions {
|
||||||
|
if it.trileName == name {
|
||||||
|
array_add(*it.positions, Vector4.{x,y,z,1});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
poses := TrilePositions.{
|
||||||
|
trileName = name,
|
||||||
|
};
|
||||||
|
|
||||||
|
array_add(*poses.positions, Vector4.{x,y,z,1});
|
||||||
|
array_add(*world.positions, poses);
|
||||||
|
} @Command
|
||||||
|
|
||||||
tick_level_editor :: () {
|
tick_level_editor :: () {
|
||||||
tick_level_editor_camera();
|
tick_level_editor_camera();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_level_editor :: () {
|
draw_level_editor :: () {
|
||||||
positions : [4096]Vector4;
|
|
||||||
positions[0] = .{1, 0, 0, 1};
|
|
||||||
positions[1] = .{0, 1, 1, 1};
|
|
||||||
|
|
||||||
draw_sky(*get_level_editor_camera(), *world.conf);
|
draw_sky(*get_level_editor_camera(), *world.conf);
|
||||||
cam := get_level_editor_camera();
|
cam := get_level_editor_camera();
|
||||||
mvp := create_viewproj(*cam);
|
mvp := create_viewproj(*cam);
|
||||||
@ -217,33 +228,37 @@ draw_level_editor :: () {
|
|||||||
vs_params.mvp = mvp.floats;
|
vs_params.mvp = mvp.floats;
|
||||||
vs_params.camera = cam.position.component;
|
vs_params.camera = cam.position.component;
|
||||||
|
|
||||||
trilegfx := get_trile_gfx(editor_current_trile.name);
|
|
||||||
|
|
||||||
sg_update_buffer(gPipelines.trile.bind.vertex_buffers[3], *(sg_range.{
|
|
||||||
ptr = positions.data,
|
|
||||||
size = size_of(type_of(positions)),
|
|
||||||
}));
|
|
||||||
|
|
||||||
sg_apply_pipeline(gPipelines.trile.pipeline);
|
sg_apply_pipeline(gPipelines.trile.pipeline);
|
||||||
|
|
||||||
world_conf : Trile_World_Config;
|
world_conf : Trile_World_Config;
|
||||||
world_config_to_shader_type(*world.conf, *world_conf);
|
world_config_to_shader_type(*world.conf, *world_conf);
|
||||||
|
|
||||||
|
for world.positions {
|
||||||
|
positions : [4096]Vector4;
|
||||||
|
trilegfx := get_trile_gfx(it.trileName);
|
||||||
|
idx : s32 = 0;
|
||||||
|
for pos : it.positions {
|
||||||
|
positions[idx] = pos;
|
||||||
|
idx += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sg_update_buffer(gPipelines.trile.bind.vertex_buffers[3], *(sg_range.{
|
||||||
bindings : sg_bindings;
|
ptr = positions.data,
|
||||||
bindings.vertex_buffers[0] = trilegfx.vertex_buffer;
|
size = size_of(type_of(positions)),
|
||||||
bindings.vertex_buffers[1] = trilegfx.normal_buffer;
|
}));
|
||||||
bindings.vertex_buffers[2] = trilegfx.centre_buffer;
|
|
||||||
bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3];
|
|
||||||
bindings.samplers[0] = gPipelines.trile.bind.samplers[0];
|
|
||||||
bindings.images[0] = trilegfx.trixel_colors;
|
|
||||||
|
|
||||||
sg_apply_bindings(*bindings);
|
bindings : sg_bindings;
|
||||||
sg_apply_uniforms(UB_trile_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params))}));
|
bindings.vertex_buffers[0] = trilegfx.vertex_buffer;
|
||||||
sg_apply_uniforms(UB_trile_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))}));
|
bindings.vertex_buffers[1] = trilegfx.normal_buffer;
|
||||||
|
bindings.vertex_buffers[2] = trilegfx.centre_buffer;
|
||||||
sg_draw(0, cast(s32) trilegfx.vertex_count, 2);
|
bindings.vertex_buffers[3] = gPipelines.trile.bind.vertex_buffers[3];
|
||||||
|
bindings.samplers[0] = gPipelines.trile.bind.samplers[0];
|
||||||
|
bindings.images[0] = trilegfx.trixel_colors;
|
||||||
|
|
||||||
|
sg_apply_bindings(*bindings);
|
||||||
|
sg_apply_uniforms(UB_trile_vs_params, *(sg_range.{ ptr = *vs_params, size = size_of(type_of(vs_params))}));
|
||||||
|
sg_apply_uniforms(UB_trile_world_config, *(sg_range.{ptr = *world_conf, size = size_of(type_of(world_conf))}));
|
||||||
|
sg_draw(0, cast(s32) trilegfx.vertex_count, idx+1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -259,7 +259,7 @@ draw_trile_editor :: () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
draw_trile :: () {
|
draw_trile :: () {
|
||||||
// if editor_current_trile == null then return;
|
if editor_current_trile == null then return;
|
||||||
cam := get_trile_editor_camera();
|
cam := get_trile_editor_camera();
|
||||||
|
|
||||||
mvp := create_viewproj(*cam);
|
mvp := create_viewproj(*cam);
|
||||||
|
|||||||
@ -155,7 +155,7 @@ trile_from_serialize_form :: (ts: TrileSerialize) -> Trile {
|
|||||||
matinfo := ts.trixels[i][j][k];
|
matinfo := ts.trixels[i][j][k];
|
||||||
mat := material_from_rgba(matinfo[1], matinfo[2], matinfo[3], matinfo[4]);
|
mat := material_from_rgba(matinfo[1], matinfo[2], matinfo[3], matinfo[4]);
|
||||||
t.trixels[i][j][k].material = mat;
|
t.trixels[i][j][k].material = mat;
|
||||||
t.trixels[i][j][k].empty = cast(bool) matinfo[0];
|
t.trixels[i][j][k].empty = matinfo[0] == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,7 +202,6 @@ draw_trile_picker :: (theme: *GR.Overall_Theme) {
|
|||||||
r.h = ui_h(4,4);
|
r.h = ui_h(4,4);
|
||||||
count := 0;
|
count := 0;
|
||||||
for v : tpt {
|
for v : tpt {
|
||||||
print("Current trile name: %\n", editor_current_trile.name);
|
|
||||||
if GR.button(r, v.name, *t_button_selectable(theme, editor_current_trile != null && editor_current_trile.name == v.name), count) {
|
if GR.button(r, v.name, *t_button_selectable(theme, editor_current_trile != null && editor_current_trile.name == v.name), count) {
|
||||||
editor_current_trile = get_trile(v.name);
|
editor_current_trile = get_trile(v.name);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,23 +32,13 @@ world_config_to_shader_type :: (wc: *World_Config, data: *$T) {
|
|||||||
#insert #run,stallable generate_copy_code();
|
#insert #run,stallable generate_copy_code();
|
||||||
}
|
}
|
||||||
|
|
||||||
IVector3 :: struct {
|
TrilePositions :: struct {
|
||||||
x: s32;
|
trileName: string;
|
||||||
y: s32;
|
positions: [..]Vector4;
|
||||||
z: s32;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ivec_comp :: (a: IVector3, b: IVector3) -> bool {
|
|
||||||
if a.x != b.x || a.y != b.y || a.z != b.z then return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ivec_hash :: (v: IVector3) -> u32 {
|
|
||||||
return sdbm_hash(*v, size_of(IVector3));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
World :: struct {
|
World :: struct {
|
||||||
conf : World_Config;
|
// @ToDo: Add a pool into here so we allocate all of the world stuff in it's own pool.
|
||||||
triles : Table(IVector3, string, ivec_hash, ivec_comp);
|
conf : World_Config;
|
||||||
|
positions : [..]TrilePositions;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user