base_math refactor progress
This commit is contained in:
parent
acc006e316
commit
a844aaa225
1
build.c
1
build.c
@ -1049,6 +1049,7 @@ void OnBuild(StringList cli_args)
|
||||
String line = StringF(&perm, Lit("#include \"%F\""), FmtStr(include_path));
|
||||
StringListAppend(&perm, &file_contents, line);
|
||||
}
|
||||
StringListAppend(&perm, &file_contents, Lit(""));
|
||||
String file_contents_str = StringFromStringList(&perm, Lit("\n"), file_contents);
|
||||
D_ClearWrite(editor_include_file, file_contents_str);
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include "base_gstat.c"
|
||||
#include "base_memory.c"
|
||||
#include "base_buddy.c"
|
||||
#include "base_math.c"
|
||||
#include "base_rand.c"
|
||||
#include "base_string.c"
|
||||
#include "base_uid.c"
|
||||
|
||||
@ -67,7 +67,7 @@ String StringFromIncbinRcResource(IncbinRcResource *inc)
|
||||
/* Spin while another thread searches */
|
||||
while (state != IncbinStatus_Searched)
|
||||
{
|
||||
ix_pause();
|
||||
IxPause();
|
||||
state = Atomic32Fetch(&inc->state);
|
||||
}
|
||||
|
||||
|
||||
@ -1,118 +1,118 @@
|
||||
/* ========================== *
|
||||
* Math
|
||||
* ========================== */
|
||||
////////////////////////////////
|
||||
//~ Sqrt intrinsics
|
||||
|
||||
/* Sqrt */
|
||||
|
||||
Inline f32 ix_sqrt_f32(f32 f)
|
||||
Inline f32 IxSqrtF32(f32 f)
|
||||
{
|
||||
__m128 n = _mm_set_ss(f);
|
||||
n = _mm_sqrt_ss(n);
|
||||
return _mm_cvtss_f32(n);
|
||||
}
|
||||
|
||||
Inline f64 ix_sqrt_f64(f64 f)
|
||||
Inline f64 IxSqrtF64(f64 f)
|
||||
{
|
||||
__m128d n = _mm_set_sd(f);
|
||||
n = _mm_sqrt_sd(_mm_setzero_pd(), n);
|
||||
return _mm_cvtsd_f64(n);
|
||||
}
|
||||
|
||||
Inline f32 ix_rsqrt_f32(f32 f)
|
||||
Inline f32 IxRsqrtF32(f32 f)
|
||||
{
|
||||
__m128 n = _mm_set_ss(f);
|
||||
n = _mm_rsqrt_ss(n);
|
||||
return _mm_cvtss_f32(n);
|
||||
}
|
||||
|
||||
/* Round */
|
||||
////////////////////////////////
|
||||
//~ Round intrinsics
|
||||
|
||||
Inline i32 ix_round_f32_to_i32(f32 f)
|
||||
Inline i32 IxRoundF32ToI32(f32 f)
|
||||
{
|
||||
return _mm_cvtss_si32(_mm_round_ss(_mm_setzero_ps(), _mm_set_ss(f), _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC));
|
||||
}
|
||||
|
||||
Inline f32 ix_round_f32_to_f32(f32 f)
|
||||
Inline f32 IxRoundF32ToF32(f32 f)
|
||||
{
|
||||
return _mm_cvtss_f32(_mm_round_ss(_mm_setzero_ps(), _mm_set_ss(f), _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC));
|
||||
}
|
||||
|
||||
Inline i64 ix_round_f64_to_i64(f64 f)
|
||||
Inline i64 IxRoundF64ToI64(f64 f)
|
||||
{
|
||||
return _mm_cvtsd_si64(_mm_round_sd(_mm_setzero_pd(), _mm_set_sd(f), _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC));
|
||||
}
|
||||
|
||||
Inline f64 ix_round_f64_to_f64(f64 f)
|
||||
Inline f64 IxRoundF64ToF64(f64 f)
|
||||
{
|
||||
return _mm_cvtsd_f64(_mm_round_sd(_mm_setzero_pd(), _mm_set_sd(f), _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC));
|
||||
}
|
||||
|
||||
/* Floor */
|
||||
////////////////////////////////
|
||||
//~ Floor intrinsics
|
||||
|
||||
Inline i32 ix_floor_f32_to_i32(f32 f)
|
||||
Inline i32 IxFloorF32ToI32(f32 f)
|
||||
{
|
||||
return _mm_cvtss_si32(_mm_floor_ss(_mm_setzero_ps(), _mm_set_ss(f)));
|
||||
}
|
||||
|
||||
Inline f32 ix_floor_f32_to_f32(f32 f)
|
||||
Inline f32 IxFloorF32ToF32(f32 f)
|
||||
{
|
||||
return _mm_cvtss_f32(_mm_floor_ss(_mm_setzero_ps(), _mm_set_ss(f)));
|
||||
}
|
||||
|
||||
Inline i64 ix_floor_f64_to_i64(f64 f)
|
||||
Inline i64 IxFloorF64ToI64(f64 f)
|
||||
{
|
||||
return _mm_cvtsd_si64(_mm_floor_sd(_mm_setzero_pd(), _mm_set_sd(f)));
|
||||
}
|
||||
|
||||
Inline f64 ix_floor_f64_to_f64(f64 f)
|
||||
Inline f64 IxFloorF64ToF64(f64 f)
|
||||
{
|
||||
return _mm_cvtsd_f64(_mm_floor_sd(_mm_setzero_pd(), _mm_set_sd(f)));
|
||||
}
|
||||
|
||||
/* Ceil */
|
||||
////////////////////////////////
|
||||
//~ Ceil intrinsics
|
||||
|
||||
Inline i32 ix_ceil_f32_to_i32(f32 f)
|
||||
Inline i32 IxCeilF32ToI32(f32 f)
|
||||
{
|
||||
return _mm_cvtss_si32(_mm_ceil_ss(_mm_setzero_ps(), _mm_set_ss(f)));
|
||||
}
|
||||
|
||||
Inline f32 ix_ceil_f32_to_f32(f32 f)
|
||||
Inline f32 IxCeilF32ToF32(f32 f)
|
||||
{
|
||||
return _mm_cvtss_f32(_mm_ceil_ss(_mm_setzero_ps(), _mm_set_ss(f)));
|
||||
}
|
||||
|
||||
Inline i64 ix_ceil_f64_to_i64(f64 f)
|
||||
Inline i64 IxCeilF64ToI64(f64 f)
|
||||
{
|
||||
return _mm_cvtsd_si64(_mm_ceil_sd(_mm_setzero_pd(), _mm_set_sd(f)));
|
||||
}
|
||||
|
||||
Inline f64 ix_ceil_f64_to_f64(f64 f)
|
||||
Inline f64 IxCeilF64ToF64(f64 f)
|
||||
{
|
||||
return _mm_cvtsd_f64(_mm_ceil_sd(_mm_setzero_pd(), _mm_set_sd(f)));
|
||||
}
|
||||
|
||||
/* Truncate */
|
||||
////////////////////////////////
|
||||
//~ Truncate intrinsics
|
||||
|
||||
Inline f32 ix_trunc_f32_to_f32(f32 f)
|
||||
Inline f32 IxTruncF32ToF32(f32 f)
|
||||
{
|
||||
return _mm_cvtss_f32(_mm_round_ss(_mm_setzero_ps(), _mm_set_ss(f), _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC));
|
||||
}
|
||||
|
||||
Inline f64 ix_trunc_f64_to_f64(f64 f)
|
||||
Inline f64 IxTruncF64ToF64(f64 f)
|
||||
{
|
||||
return _mm_cvtsd_f64(_mm_round_sd(_mm_setzero_pd(), _mm_set_sd(f), _MM_FROUND_TO_ZERO | _MM_FROUND_NO_EXC));
|
||||
}
|
||||
|
||||
/* ========================== *
|
||||
* Util
|
||||
* ========================== */
|
||||
////////////////////////////////
|
||||
//~ Utility intrinsics
|
||||
|
||||
Inline void ix_pause(void)
|
||||
Inline void IxPause(void)
|
||||
{
|
||||
_mm_pause();
|
||||
}
|
||||
|
||||
Inline u64 ix_clock(void)
|
||||
Inline u64 IxClock(void)
|
||||
{
|
||||
return __rdtsc();
|
||||
}
|
||||
|
||||
1444
src/base/base_math.c
Normal file
1444
src/base/base_math.c
Normal file
File diff suppressed because it is too large
Load Diff
1515
src/base/base_math.h
1515
src/base/base_math.h
File diff suppressed because it is too large
Load Diff
@ -951,7 +951,7 @@ V2Array menkowski(Arena *arena, CLD_Shape *shape0, CLD_Shape *shape1, Xform xf0,
|
||||
{
|
||||
V2Array res = { .points = PushDry(arena, V2) };
|
||||
for (u64 i = 0; i < detail; ++i) {
|
||||
f32 angle = ((f32)i / detail) * (2 * PI);
|
||||
f32 angle = ((f32)i / detail) * (2 * Pi);
|
||||
V2 dir = v2_from_angle(angle);
|
||||
CLD_MenkowskiPoint m = get_menkowski_point(shape0, shape1, xf0, xf1, dir);
|
||||
if (res.count == 0 || !v2_eq(m.p, res.points[res.count - 1])) {
|
||||
|
||||
@ -63,7 +63,7 @@
|
||||
|
||||
#if 0
|
||||
# define SIM_MAX_LINEAR_VELOCITY 500
|
||||
# define SIM_MAX_ANGULAR_VELOCITY (TAU * 20)
|
||||
# define SIM_MAX_ANGULAR_VELOCITY (Tau * 20)
|
||||
#else
|
||||
# define SIM_MAX_LINEAR_VELOCITY F32_INFINITY
|
||||
# define SIM_MAX_ANGULAR_VELOCITY F32_INFINITY
|
||||
|
||||
@ -11,7 +11,7 @@ D_StartupReceipt draw_startup(F_StartupReceipt *font_sr)
|
||||
__prof;
|
||||
(UNUSED)font_sr;
|
||||
u32 pixel_white = 0xFFFFFFFF;
|
||||
G.solid_white_texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, V2i32FromXY(1, 1), &pixel_white);
|
||||
G.solid_white_texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, V2I32FromXY(1, 1), &pixel_white);
|
||||
return (D_StartupReceipt) { 0 };
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ void draw_circle(G_RenderSig *sig, V2 pos, f32 radius, u32 color, u32 detail)
|
||||
|
||||
V2 *points = PushArrayNoZero(scratch.arena, V2, detail);
|
||||
for (u32 i = 0; i < detail; ++i) {
|
||||
f32 angle = ((f32)i / (f32)detail) * TAU;
|
||||
f32 angle = ((f32)i / (f32)detail) * Tau;
|
||||
V2 p = V2FromXY(
|
||||
radius * math_cos(angle),
|
||||
radius * math_sin(angle)
|
||||
@ -160,7 +160,7 @@ void draw_circle_line(G_RenderSig *sig, V2 pos, f32 radius, f32 thickness, u32 c
|
||||
|
||||
V2 *points = PushArrayNoZero(scratch.arena, V2, detail);
|
||||
for (u32 i = 0; i < detail; ++i) {
|
||||
f32 angle = ((f32)i / (f32)detail) * TAU;
|
||||
f32 angle = ((f32)i / (f32)detail) * Tau;
|
||||
V2 p = V2FromXY(
|
||||
radius * math_cos(angle),
|
||||
radius * math_sin(angle)
|
||||
@ -235,7 +235,7 @@ void draw_collider_line(G_RenderSig *sig, CLD_Shape shape, Xform shape_xf, f32 t
|
||||
poly.count = detail;
|
||||
poly.points = PushArrayNoZero(scratch.arena, V2, detail);
|
||||
for (u32 i = 0; i < detail; ++i) {
|
||||
f32 angle = ((f32)i / (f32)detail) * TAU;
|
||||
f32 angle = ((f32)i / (f32)detail) * Tau;
|
||||
V2 dir = V2FromXY(math_cos(angle), math_sin(angle));
|
||||
V2 p = collider_get_support_point(&shape, shape_xf, dir).p;
|
||||
poly.points[i] = p;
|
||||
@ -461,7 +461,7 @@ Rect draw_text(G_RenderSig *sig, D_TextParams params)
|
||||
struct drawable_glyph *tg = &line->glyphs[i];
|
||||
V2 pos = V2FromXY(draw_pos.x + tg->off_x, draw_pos.y + tg->off_y);
|
||||
V2 size = V2FromXY(tg->width, tg->height);
|
||||
Xform xf = xform_from_rect(RECT_FROM_V2(pos, size));
|
||||
Xform xf = xform_from_rect(RectFromV2(pos, size));
|
||||
draw_ui_rect(sig, DRAW_UI_RECT_PARAMS(.xf = xf, .texture = params.font->texture, .tint = params.color, .clip = tg->clip));
|
||||
draw_pos.x += tg->advance;
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ D_StartupReceipt draw_startup(F_StartupReceipt *font_sr);
|
||||
|
||||
#define DRAW_MATERIAL_PARAMS(...) ((D_MaterialParams) { \
|
||||
.tint = ColorWhite, \
|
||||
.clip = CLIP_ALL, \
|
||||
.clip = ClipAll, \
|
||||
__VA_ARGS__ \
|
||||
})
|
||||
|
||||
@ -68,7 +68,7 @@ void draw_grid(G_RenderSig *sig, Xform xf, u32 bg0_color, u32 bg1_color, u32 lin
|
||||
|
||||
#define DRAW_UI_RECT_PARAMS(...) ((D_UiRectParams) { \
|
||||
.tint = ColorWhite, \
|
||||
.clip = CLIP_ALL, \
|
||||
.clip = ClipAll, \
|
||||
__VA_ARGS__ \
|
||||
})
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ internal P_JobDef(font_load_asset_job, job)
|
||||
resource_close(&res);
|
||||
|
||||
/* Send texture to GPU */
|
||||
G_Resource *texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, V2i32FromXY(result.image_width, result.image_height), result.image_pixels);
|
||||
G_Resource *texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, V2I32FromXY(result.image_width, result.image_height), result.image_pixels);
|
||||
|
||||
/* Allocate store memory */
|
||||
F_Font *font = 0;
|
||||
|
||||
@ -69,8 +69,8 @@ Struct(G_RenderCmdDesc)
|
||||
|
||||
Struct(G_RenderParams)
|
||||
{
|
||||
V2i32 ui_size;
|
||||
V2i32 render_size;
|
||||
V2I32 ui_size;
|
||||
V2I32 render_size;
|
||||
Xform world_to_render_xf;
|
||||
Xform render_to_ui_xf;
|
||||
b32 effects_disabled;
|
||||
@ -125,9 +125,9 @@ void gp_resource_release(G_Resource *resource);
|
||||
////////////////////////////////
|
||||
//~ Texture operations
|
||||
|
||||
G_Resource *gp_texture_alloc(G_TextureFormat format, u32 flags, V2i32 size, void *initial_data);
|
||||
G_Resource *gp_texture_alloc(G_TextureFormat format, u32 flags, V2I32 size, void *initial_data);
|
||||
|
||||
V2i32 gp_texture_get_size(G_Resource *texture);
|
||||
V2I32 gp_texture_get_size(G_Resource *texture);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Render operations
|
||||
@ -147,7 +147,7 @@ G_MemoryInfo gp_query_memory_info(void);
|
||||
////////////////////////////////
|
||||
//~ Swapchain
|
||||
|
||||
G_Swapchain *gp_swapchain_alloc(P_Window *window, V2i32 resolution);
|
||||
G_Swapchain *gp_swapchain_alloc(P_Window *window, V2I32 resolution);
|
||||
|
||||
void gp_swapchain_release(G_Swapchain *gp_swapchain);
|
||||
|
||||
@ -161,4 +161,4 @@ void gp_swapchain_wait(G_Swapchain *gp_swapchain);
|
||||
/* 1. Clears the backbuffer and ensures it's at size `backbuffer_resolution`
|
||||
* 2. Blits `texture` to the backbuffer using `texture_xf`
|
||||
* 3. Presents the backbuffer */
|
||||
void gp_present(G_Swapchain *gp_swapchain, V2i32 backbuffer_resolution, G_Resource *texture, Xform texture_xf, i32 vsync);
|
||||
void gp_present(G_Swapchain *gp_swapchain, V2I32 backbuffer_resolution, G_Resource *texture, Xform texture_xf, i32 vsync);
|
||||
|
||||
@ -214,7 +214,7 @@ struct dx12_resource {
|
||||
|
||||
D3D12_GPU_VIRTUAL_ADDRESS gpu_address; /* NOTE: 0 for textures */
|
||||
|
||||
V2i32 texture_size;
|
||||
V2I32 texture_size;
|
||||
struct dx12_resource *next_free;
|
||||
};
|
||||
|
||||
@ -229,7 +229,7 @@ struct swapchain {
|
||||
IDXGISwapChain3 *swapchain;
|
||||
HWND hwnd;
|
||||
HANDLE waitable;
|
||||
V2i32 resolution;
|
||||
V2I32 resolution;
|
||||
struct swapchain_buffer buffers[DX12_SWAPCHAIN_BUFFER_COUNT];
|
||||
|
||||
struct swapchain *next_free;
|
||||
@ -2204,7 +2204,7 @@ internal P_JobDef(dx12_wait_fence_job, job)
|
||||
* Texture
|
||||
* ========================== */
|
||||
|
||||
G_Resource *gp_texture_alloc(G_TextureFormat format, u32 flags, V2i32 size, void *initial_data)
|
||||
G_Resource *gp_texture_alloc(G_TextureFormat format, u32 flags, V2I32 size, void *initial_data)
|
||||
{
|
||||
__prof;
|
||||
if (size.x <= 0 || size.y <= 0) {
|
||||
@ -2271,7 +2271,7 @@ G_Resource *gp_texture_alloc(G_TextureFormat format, u32 flags, V2i32 size, void
|
||||
return (G_Resource *)r;
|
||||
}
|
||||
|
||||
V2i32 gp_texture_get_size(G_Resource *resource)
|
||||
V2I32 gp_texture_get_size(G_Resource *resource)
|
||||
{
|
||||
struct dx12_resource *r = (struct dx12_resource *)resource;
|
||||
return r->texture_size;
|
||||
@ -2458,7 +2458,7 @@ internal D3D12_INDEX_BUFFER_VIEW ibv_from_command_buffer(struct command_buffer *
|
||||
return ibv;
|
||||
}
|
||||
|
||||
internal struct dx12_resource *gbuff_alloc(DXGI_FORMAT format, V2i32 size, D3D12_RESOURCE_STATES initial_state)
|
||||
internal struct dx12_resource *gbuff_alloc(DXGI_FORMAT format, V2I32 size, D3D12_RESOURCE_STATES initial_state)
|
||||
{
|
||||
__prof;
|
||||
D3D12_HEAP_PROPERTIES heap_props = { .Type = D3D12_HEAP_TYPE_DEFAULT };
|
||||
@ -2695,13 +2695,13 @@ G_Resource *gp_run_render(G_RenderSig *gp_render_sig, G_RenderParams params)
|
||||
struct render_sig *rsig = (struct render_sig *)gp_render_sig;
|
||||
++rsig->frame_index;
|
||||
|
||||
V2i32 ui_size = V2i32FromXY(max_i32(params.ui_size.x, 1), max_i32(params.ui_size.y, 1));
|
||||
V2i32 render_size = V2i32FromXY(max_i32(params.render_size.x, 1), max_i32(params.render_size.y, 1));
|
||||
V2I32 ui_size = V2I32FromXY(max_i32(params.ui_size.x, 1), max_i32(params.ui_size.y, 1));
|
||||
V2I32 render_size = V2I32FromXY(max_i32(params.render_size.x, 1), max_i32(params.render_size.y, 1));
|
||||
Xform world_to_render_xf = params.world_to_render_xf;
|
||||
Xform render_to_ui_xf = params.render_to_ui_xf;
|
||||
|
||||
Rect ui_viewport = RECT_FROM_V2(V2FromXY(0, 0), V2FromXY(ui_size.x, ui_size.y));
|
||||
Rect render_viewport = RECT_FROM_V2(V2FromXY(0, 0), V2FromXY(render_size.x, render_size.y));
|
||||
Rect ui_viewport = RectFromV2(V2FromXY(0, 0), V2FromXY(ui_size.x, ui_size.y));
|
||||
Rect render_viewport = RectFromV2(V2FromXY(0, 0), V2FromXY(render_size.x, render_size.y));
|
||||
|
||||
|
||||
/* Allocate render buffers */
|
||||
@ -3201,7 +3201,7 @@ internal void swapchain_init_resources(struct swapchain *swapchain)
|
||||
}
|
||||
}
|
||||
|
||||
G_Swapchain *gp_swapchain_alloc(P_Window *window, V2i32 resolution)
|
||||
G_Swapchain *gp_swapchain_alloc(P_Window *window, V2I32 resolution)
|
||||
{
|
||||
HRESULT hr = 0;
|
||||
HWND hwnd = (HWND)P_GetInternalWindowHandle(window);
|
||||
@ -3282,7 +3282,7 @@ void gp_swapchain_wait(G_Swapchain *gp_swapchain)
|
||||
#endif
|
||||
}
|
||||
|
||||
internal struct swapchain_buffer *update_swapchain(struct swapchain *swapchain, V2i32 resolution)
|
||||
internal struct swapchain_buffer *update_swapchain(struct swapchain *swapchain, V2I32 resolution)
|
||||
{
|
||||
__prof;
|
||||
resolution.x = max_i32(resolution.x, 1);
|
||||
@ -3360,7 +3360,7 @@ internal void present_blit(struct swapchain_buffer *dst, struct dx12_resource *s
|
||||
ID3D12DescriptorHeap *heaps[] = { descriptor_heap->heap };
|
||||
ID3D12GraphicsCommandList_SetDescriptorHeaps(cl->cl, countof(heaps), heaps);
|
||||
|
||||
Rect viewport_rect = RECT_FROM_V2(V2FromXY(0, 0), V2FromXY(swapchain->resolution.x, swapchain->resolution.y));
|
||||
Rect viewport_rect = RectFromV2(V2FromXY(0, 0), V2FromXY(swapchain->resolution.x, swapchain->resolution.y));
|
||||
D3D12_VIEWPORT viewport = viewport_from_rect(viewport_rect);
|
||||
D3D12_RECT scissor = scissor_from_rect(viewport_rect);
|
||||
|
||||
@ -3434,7 +3434,7 @@ internal void present_blit(struct swapchain_buffer *dst, struct dx12_resource *s
|
||||
pipeline_scope_end(pipeline_scope);
|
||||
}
|
||||
|
||||
void gp_present(G_Swapchain *gp_swapchain, V2i32 backbuffer_resolution, G_Resource *texture, Xform texture_xf, i32 vsync)
|
||||
void gp_present(G_Swapchain *gp_swapchain, V2I32 backbuffer_resolution, G_Resource *texture, Xform texture_xf, i32 vsync)
|
||||
{
|
||||
__prof;
|
||||
struct swapchain *swapchain = (struct swapchain *)gp_swapchain;
|
||||
|
||||
@ -96,8 +96,8 @@ Inline struct K_float2x3 K_Float2x3FromXform(Xform v)
|
||||
|
||||
#define DECLS(t, n) t n : n
|
||||
|
||||
#define TAU 6.28318530718
|
||||
#define PI 3.14159265359
|
||||
#define Tau 6.28318530718
|
||||
#define Pi 3.14159265359
|
||||
#define GOLDEN 1.61803398875
|
||||
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ float rand_angle(uint2 pos, uint ray_index) {
|
||||
// noise_coord.xy -= sig.camera_offset;
|
||||
|
||||
uint noise = noise_tex[noise_coord % uint3(K_BLUE_NOISE_TEX_WIDTH, K_BLUE_NOISE_TEX_HEIGHT, K_BLUE_NOISE_TEX_DEPTH)];
|
||||
return ((float)noise / (float)0xFFFF) * TAU;
|
||||
return ((float)noise / (float)0xFFFF) * Tau;
|
||||
}
|
||||
|
||||
float3 get_light_in_dir(uint2 ray_start, float2 ray_dir)
|
||||
|
||||
@ -45,7 +45,7 @@ P_Lock P_LockSpinE(P_Mutex *m, i32 spin)
|
||||
{
|
||||
if (spin_cnt < spin)
|
||||
{
|
||||
ix_pause();
|
||||
IxPause();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -92,7 +92,7 @@ P_Lock P_LockSpinS(P_Mutex *m, i32 spin)
|
||||
{
|
||||
if (spin_cnt < spin)
|
||||
{
|
||||
ix_pause();
|
||||
IxPause();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -22,7 +22,7 @@ void P_W32_LockTicketMutex(P_W32_TicketMutex *tm)
|
||||
i64 ticket = Atomic64FetchAdd(&tm->ticket.v, 1);
|
||||
while (Atomic64Fetch(&tm->serving.v) != ticket)
|
||||
{
|
||||
ix_pause();
|
||||
IxPause();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3202,7 +3202,7 @@ void P_SleepPrecise(i64 sleep_time_ns)
|
||||
__profn("Sleep spin");
|
||||
while (now_ns < target_ns)
|
||||
{
|
||||
ix_pause();
|
||||
IxPause();
|
||||
now_ns = P_TimeNs();
|
||||
}
|
||||
}
|
||||
|
||||
@ -540,15 +540,15 @@ Snapshot *sim_snapshot_from_closest_tick_gte(Client *client, u64 tick)
|
||||
* Tile
|
||||
* ========================== */
|
||||
|
||||
V2i32 sim_world_tile_index_from_pos(V2 pos)
|
||||
V2I32 sim_world_tile_index_from_pos(V2 pos)
|
||||
{
|
||||
V2i32 res = V2i32FromXY(pos.x * SIM_TILES_PER_UNIT_SQRT, pos.y * SIM_TILES_PER_UNIT_SQRT);
|
||||
V2I32 res = V2I32FromXY(pos.x * SIM_TILES_PER_UNIT_SQRT, pos.y * SIM_TILES_PER_UNIT_SQRT);
|
||||
res.x -= pos.x < 0;
|
||||
res.y -= pos.y < 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
V2 sim_pos_from_world_tile_index(V2i32 world_tile_index)
|
||||
V2 sim_pos_from_world_tile_index(V2I32 world_tile_index)
|
||||
{
|
||||
V2 res = ZI;
|
||||
f32 tile_size = 1.f / SIM_TILES_PER_UNIT_SQRT;
|
||||
@ -557,9 +557,9 @@ V2 sim_pos_from_world_tile_index(V2i32 world_tile_index)
|
||||
return res;
|
||||
}
|
||||
|
||||
V2i32 sim_local_tile_index_from_world_tile_index(V2i32 world_tile_index)
|
||||
V2I32 sim_local_tile_index_from_world_tile_index(V2I32 world_tile_index)
|
||||
{
|
||||
V2i32 res = world_tile_index;
|
||||
V2I32 res = world_tile_index;
|
||||
res.x += res.x < 0;
|
||||
res.y += res.y < 0;
|
||||
res.x = res.x % SIM_TILES_PER_CHUNK_SQRT;
|
||||
@ -569,17 +569,17 @@ V2i32 sim_local_tile_index_from_world_tile_index(V2i32 world_tile_index)
|
||||
return res;
|
||||
}
|
||||
|
||||
V2i32 sim_world_tile_index_from_local_tile_index(V2i32 tile_chunk_index, V2i32 local_tile_index)
|
||||
V2I32 sim_world_tile_index_from_local_tile_index(V2I32 tile_chunk_index, V2I32 local_tile_index)
|
||||
{
|
||||
V2i32 res = ZI;
|
||||
V2I32 res = ZI;
|
||||
res.x = (tile_chunk_index.x * SIM_TILES_PER_CHUNK_SQRT) + local_tile_index.x;
|
||||
res.y = (tile_chunk_index.y * SIM_TILES_PER_CHUNK_SQRT) + local_tile_index.y;
|
||||
return res;
|
||||
}
|
||||
|
||||
V2i32 sim_tile_chunk_index_from_world_tile_index(V2i32 world_tile_index)
|
||||
V2I32 sim_tile_chunk_index_from_world_tile_index(V2I32 world_tile_index)
|
||||
{
|
||||
V2i32 res = world_tile_index;
|
||||
V2I32 res = world_tile_index;
|
||||
res.x += res.x < 0;
|
||||
res.y += res.y < 0;
|
||||
res.x = res.x / SIM_TILES_PER_CHUNK_SQRT;
|
||||
@ -589,9 +589,9 @@ V2i32 sim_tile_chunk_index_from_world_tile_index(V2i32 world_tile_index)
|
||||
return res;
|
||||
}
|
||||
|
||||
void sim_snapshot_set_tile(Snapshot *ss, V2i32 world_tile_index, TileKind tile_kind)
|
||||
void sim_snapshot_set_tile(Snapshot *ss, V2I32 world_tile_index, TileKind tile_kind)
|
||||
{
|
||||
V2i32 chunk_index = sim_tile_chunk_index_from_world_tile_index(world_tile_index);
|
||||
V2I32 chunk_index = sim_tile_chunk_index_from_world_tile_index(world_tile_index);
|
||||
|
||||
EntId chunk_id = sim_ent_tile_chunk_id_from_tile_chunk_index(chunk_index);
|
||||
Ent *chunk_ent = sim_ent_from_id(ss, chunk_id);
|
||||
@ -602,7 +602,7 @@ void sim_snapshot_set_tile(Snapshot *ss, V2i32 world_tile_index, TileKind tile_k
|
||||
chunk_ent->tile_chunk_index = chunk_index;
|
||||
}
|
||||
|
||||
V2i32 local_index = sim_local_tile_index_from_world_tile_index(world_tile_index);
|
||||
V2I32 local_index = sim_local_tile_index_from_world_tile_index(world_tile_index);
|
||||
chunk_ent->tile_chunk_tiles[local_index.x + (local_index.y * SIM_TILES_PER_CHUNK_SQRT)] = tile_kind;
|
||||
}
|
||||
|
||||
|
||||
@ -233,12 +233,12 @@ Snapshot *sim_snapshot_from_closest_tick_lte(Client *client, u64 tick);
|
||||
Snapshot *sim_snapshot_from_closest_tick_gte(Client *client, u64 tick);
|
||||
|
||||
/* Tile */
|
||||
V2i32 sim_world_tile_index_from_pos(V2 pos);
|
||||
V2 sim_pos_from_world_tile_index(V2i32 world_tile_index);
|
||||
V2i32 sim_local_tile_index_from_world_tile_index(V2i32 world_tile_index);
|
||||
V2i32 sim_world_tile_index_from_local_tile_index(V2i32 tile_chunk_index, V2i32 local_tile_index);
|
||||
V2i32 sim_tile_chunk_index_from_world_tile_index(V2i32 world_tile_index);
|
||||
void sim_snapshot_set_tile(Snapshot *ss, V2i32 world_tile_index, TileKind tile_kind);
|
||||
V2I32 sim_world_tile_index_from_pos(V2 pos);
|
||||
V2 sim_pos_from_world_tile_index(V2I32 world_tile_index);
|
||||
V2I32 sim_local_tile_index_from_world_tile_index(V2I32 world_tile_index);
|
||||
V2I32 sim_world_tile_index_from_local_tile_index(V2I32 tile_chunk_index, V2I32 local_tile_index);
|
||||
V2I32 sim_tile_chunk_index_from_world_tile_index(V2I32 world_tile_index);
|
||||
void sim_snapshot_set_tile(Snapshot *ss, V2I32 world_tile_index, TileKind tile_kind);
|
||||
|
||||
/* Lerp */
|
||||
Snapshot *sim_snapshot_alloc_from_lerp(Client *client, Snapshot *ss0, Snapshot *ss1, f64 blend);
|
||||
|
||||
@ -289,7 +289,7 @@ EntId sim_ent_collision_debug_id_from_ids(EntId player_id, EntId id0, EntId id1)
|
||||
}
|
||||
|
||||
/* Returns the deterministic id of the tile chunk that should be produced at chunk pos */
|
||||
EntId sim_ent_tile_chunk_id_from_tile_chunk_index(V2i32 chunk_index)
|
||||
EntId sim_ent_tile_chunk_id_from_tile_chunk_index(V2I32 chunk_index)
|
||||
{
|
||||
EntId res = ZI;
|
||||
res.uid = SIM_ENT_TILE_CHUNK_BASIS_UID;
|
||||
@ -559,21 +559,21 @@ void sim_ent_apply_torque(Ent *ent, f32 torque)
|
||||
* Tile
|
||||
* ========================== */
|
||||
|
||||
Ent *sim_tile_chunk_from_chunk_index(Snapshot *ss, V2i32 chunk_index)
|
||||
Ent *sim_tile_chunk_from_chunk_index(Snapshot *ss, V2I32 chunk_index)
|
||||
{
|
||||
EntId chunk_id = sim_ent_tile_chunk_id_from_tile_chunk_index(chunk_index);
|
||||
Ent *chunk_ent = sim_ent_from_id(ss, chunk_id);
|
||||
return chunk_ent;
|
||||
}
|
||||
|
||||
Ent *sim_tile_chunk_from_world_tile_index(Snapshot *ss, V2i32 world_tile_index)
|
||||
Ent *sim_tile_chunk_from_world_tile_index(Snapshot *ss, V2I32 world_tile_index)
|
||||
{
|
||||
V2i32 chunk_index = sim_tile_chunk_index_from_world_tile_index(world_tile_index);
|
||||
V2I32 chunk_index = sim_tile_chunk_index_from_world_tile_index(world_tile_index);
|
||||
Ent *chunk_ent = sim_tile_chunk_from_chunk_index(ss, chunk_index);
|
||||
return chunk_ent;
|
||||
}
|
||||
|
||||
TileKind sim_get_chunk_tile(Ent *chunk_ent, V2i32 local_tile_index)
|
||||
TileKind sim_get_chunk_tile(Ent *chunk_ent, V2I32 local_tile_index)
|
||||
{
|
||||
TileKind res = chunk_ent->tile_chunk_tiles[local_tile_index.x + (local_tile_index.y * SIM_TILES_PER_CHUNK_SQRT)];
|
||||
return res;
|
||||
|
||||
@ -157,7 +157,7 @@ Struct(Ent) {
|
||||
|
||||
/* FIXME: Move out of here */
|
||||
u8 tile_chunk_tiles[SIM_TILES_PER_CHUNK_SQRT * SIM_TILES_PER_CHUNK_SQRT];
|
||||
V2i32 tile_chunk_index;
|
||||
V2I32 tile_chunk_index;
|
||||
|
||||
/* ====================================================================== */
|
||||
/* Client */
|
||||
@ -508,7 +508,7 @@ Ent *sim_ent_from_id(Snapshot *ss, EntId id);
|
||||
EntId sim_ent_random_id(void);
|
||||
EntId sim_ent_contact_constraint_id_from_contacting_ids(EntId player_id, EntId id0, EntId id1);
|
||||
EntId sim_ent_collision_debug_id_from_ids(EntId player_id, EntId id0, EntId id1);
|
||||
EntId sim_ent_tile_chunk_id_from_tile_chunk_index(V2i32 chunk_start);
|
||||
EntId sim_ent_tile_chunk_id_from_tile_chunk_index(V2I32 chunk_start);
|
||||
|
||||
/* Query */
|
||||
Ent *sim_ent_find_first_match_one(Snapshot *ss, EntProp prop);
|
||||
@ -534,9 +534,9 @@ void sim_ent_apply_angular_impulse(Ent *ent, f32 impulse);
|
||||
void sim_ent_apply_torque(Ent *ent, f32 torque);
|
||||
|
||||
/* Tile */
|
||||
Ent *sim_tile_chunk_from_chunk_index(Snapshot *ss, V2i32 chunk_index);
|
||||
Ent *sim_tile_chunk_from_world_tile_index(Snapshot *ss, V2i32 world_tile_index);
|
||||
TileKind sim_get_chunk_tile(Ent *chunk_ent, V2i32 local_tile_index);
|
||||
Ent *sim_tile_chunk_from_chunk_index(Snapshot *ss, V2I32 chunk_index);
|
||||
Ent *sim_tile_chunk_from_world_tile_index(Snapshot *ss, V2I32 world_tile_index);
|
||||
TileKind sim_get_chunk_tile(Ent *chunk_ent, V2I32 local_tile_index);
|
||||
|
||||
/* Lerp */
|
||||
void sim_ent_lerp(Ent *e, Ent *e0, Ent *e1, f64 blend);
|
||||
|
||||
@ -69,16 +69,16 @@ Space *space_from_entry(SpaceEntry *entry)
|
||||
* Cell
|
||||
* ========================== */
|
||||
|
||||
internal V2i32 world_to_cell_coords(f32 cell_size, V2 world_pos)
|
||||
internal V2I32 world_to_cell_coords(f32 cell_size, V2 world_pos)
|
||||
{
|
||||
f32 x = world_pos.x;
|
||||
f32 y = world_pos.y;
|
||||
x = (x + ((x >= 0) - (x < 0)) * cell_size) / cell_size;
|
||||
y = (y + ((y >= 0) - (y < 0)) * cell_size) / cell_size;
|
||||
return V2i32FromXY((i32)x, (i32)y);
|
||||
return V2I32FromXY((i32)x, (i32)y);
|
||||
}
|
||||
|
||||
internal i32 cell_coords_to_bin_index(Space *space, V2i32 cell_pos)
|
||||
internal i32 cell_coords_to_bin_index(Space *space, V2I32 cell_pos)
|
||||
{
|
||||
i32 num_bins_sqrt = space->num_bins_sqrt;
|
||||
|
||||
@ -100,7 +100,7 @@ internal i32 cell_coords_to_bin_index(Space *space, V2i32 cell_pos)
|
||||
return bin_index;
|
||||
}
|
||||
|
||||
SpaceCell *space_get_cell(Space *space, V2i32 cell_pos)
|
||||
SpaceCell *space_get_cell(Space *space, V2I32 cell_pos)
|
||||
{
|
||||
i32 bin_index = cell_coords_to_bin_index(space, cell_pos);
|
||||
SpaceCellBin *bin = &space->bins[bin_index];
|
||||
@ -114,7 +114,7 @@ SpaceCell *space_get_cell(Space *space, V2i32 cell_pos)
|
||||
return res;
|
||||
}
|
||||
|
||||
internal void space_cell_node_alloc(V2i32 cell_pos, SpaceEntry *entry)
|
||||
internal void space_cell_node_alloc(V2I32 cell_pos, SpaceEntry *entry)
|
||||
{
|
||||
Space *space = space_from_entry(entry);
|
||||
i32 bin_index = cell_coords_to_bin_index(space, cell_pos);
|
||||
@ -311,22 +311,22 @@ void space_entry_update_aabb(SpaceEntry *entry, Aabb new_aabb)
|
||||
Space *space = space_from_entry(entry);
|
||||
f32 cell_size = space->cell_size;
|
||||
|
||||
V2i32 old_cell_p0 = V2i32FromXY(0, 0);
|
||||
V2i32 old_cell_p1 = V2i32FromXY(0, 0);
|
||||
V2I32 old_cell_p0 = V2I32FromXY(0, 0);
|
||||
V2I32 old_cell_p1 = V2I32FromXY(0, 0);
|
||||
if (entry->first_node) {
|
||||
Aabb old_aabb = entry->aabb;
|
||||
old_cell_p0 = world_to_cell_coords(cell_size, old_aabb.p0);
|
||||
old_cell_p1 = world_to_cell_coords(cell_size, old_aabb.p1);
|
||||
}
|
||||
|
||||
V2i32 new_cell_p0 = world_to_cell_coords(cell_size, new_aabb.p0);
|
||||
V2i32 new_cell_p1 = world_to_cell_coords(cell_size, new_aabb.p1);
|
||||
V2I32 new_cell_p0 = world_to_cell_coords(cell_size, new_aabb.p0);
|
||||
V2I32 new_cell_p1 = world_to_cell_coords(cell_size, new_aabb.p1);
|
||||
|
||||
/* Release outdated nodes */
|
||||
SpaceCellNode *n = entry->first_node;
|
||||
while (n) {
|
||||
SpaceCell *cell = n->cell;
|
||||
V2i32 cell_pos = cell->pos;
|
||||
V2I32 cell_pos = cell->pos;
|
||||
if (cell_pos.x < new_cell_p0.x || cell_pos.x > new_cell_p1.x || cell_pos.y < new_cell_p0.y || cell_pos.y > new_cell_p1.y) {
|
||||
/* Cell is outside of new AABB */
|
||||
SpaceCellNode *next = n->next_in_entry;
|
||||
@ -342,7 +342,7 @@ void space_entry_update_aabb(SpaceEntry *entry, Aabb new_aabb)
|
||||
for (i32 x = new_cell_p0.x; x <= new_cell_p1.x; ++x) {
|
||||
if (x != 0 && y != 0 && (x < old_cell_p0.x || x > old_cell_p1.x || y < old_cell_p0.y || y > old_cell_p1.y)) {
|
||||
/* Cell is outside of old AABB */
|
||||
space_cell_node_alloc(V2i32FromXY(x, y), entry);
|
||||
space_cell_node_alloc(V2I32FromXY(x, y), entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -364,7 +364,7 @@ SpaceIter space_iter_begin_aabb(Space *space, Aabb aabb)
|
||||
iter.cell_end = world_to_cell_coords(cell_size, aabb.p1);
|
||||
if (iter.cell_start.x > iter.cell_end.x || iter.cell_start.y > iter.cell_end.y) {
|
||||
/* Swap cell_start & cell_end */
|
||||
V2i32 tmp = iter.cell_start;
|
||||
V2I32 tmp = iter.cell_start;
|
||||
iter.cell_start = iter.cell_end;
|
||||
iter.cell_end = tmp;
|
||||
}
|
||||
@ -381,9 +381,9 @@ SpaceEntry *space_iter_next(SpaceIter *iter)
|
||||
{
|
||||
Space *space = iter->space;
|
||||
Aabb iter_aabb = iter->aabb;
|
||||
V2i32 cell_start = iter->cell_start;
|
||||
V2i32 cell_end = iter->cell_end;
|
||||
V2i32 cell_cur = iter->cell_cur;
|
||||
V2I32 cell_start = iter->cell_start;
|
||||
V2I32 cell_end = iter->cell_end;
|
||||
V2I32 cell_cur = iter->cell_cur;
|
||||
i32 span = cell_end.x - cell_start.x;
|
||||
|
||||
SpaceCellNode *next_node = 0;
|
||||
|
||||
@ -42,7 +42,7 @@ typedef struct SpaceCellBin SpaceCellBin;
|
||||
typedef struct SpaceCell SpaceCell;
|
||||
struct SpaceCell {
|
||||
b32 valid;
|
||||
V2i32 pos;
|
||||
V2I32 pos;
|
||||
|
||||
SpaceCellNode *first_node;
|
||||
SpaceCellNode *last_node;
|
||||
@ -82,9 +82,9 @@ typedef struct SpaceIter SpaceIter;
|
||||
struct SpaceIter {
|
||||
Aabb aabb;
|
||||
Space *space;
|
||||
V2i32 cell_start;
|
||||
V2i32 cell_end;
|
||||
V2i32 cell_cur;
|
||||
V2I32 cell_start;
|
||||
V2I32 cell_end;
|
||||
V2I32 cell_cur;
|
||||
SpaceCellNode *prev;
|
||||
};
|
||||
|
||||
@ -124,7 +124,7 @@ Space *space_from_entry(SpaceEntry *entry);
|
||||
* Cell
|
||||
* ========================== */
|
||||
|
||||
SpaceCell *space_get_cell(Space *space, V2i32 cell_pos);
|
||||
SpaceCell *space_get_cell(Space *space, V2I32 cell_pos);
|
||||
|
||||
/* ========================== *
|
||||
* Entry
|
||||
|
||||
@ -114,7 +114,7 @@ internal Ent *test_spawn_employee(Ent *parent)
|
||||
//V2 size = V2FromXY(0.5, 0.25);
|
||||
V2 size = V2FromXY(1.0, 1.0);
|
||||
|
||||
//f32 r = PI / 4;
|
||||
//f32 r = Pi / 4;
|
||||
f32 r = 0;
|
||||
|
||||
{
|
||||
@ -262,7 +262,7 @@ internal void test_spawn_entities2(Ent *parent, V2 pos)
|
||||
//e->sprite_tint = Alpha32F(ColorWhite, 1);
|
||||
|
||||
sim_ent_enable_prop(e, SEPROP_SOLID);
|
||||
Quad collider_quad = quad_from_rect(RECT(-0.5, -0.5, 1, 1));
|
||||
Quad collider_quad = quad_from_rect(RectFromScalar(-0.5, -0.5, 1, 1));
|
||||
e->local_collider = collider_from_quad(collider_quad);
|
||||
|
||||
sim_ent_enable_prop(e, SEPROP_LIGHT_TEST);
|
||||
@ -292,7 +292,7 @@ internal void test_spawn_entities2(Ent *parent, V2 pos)
|
||||
{
|
||||
Ent *e = sim_ent_alloc_sync_src(parent);
|
||||
|
||||
f32 r = PI / 4;
|
||||
f32 r = Pi / 4;
|
||||
V2 size = V2FromXY(0.5, 0.25);
|
||||
Xform xf = XFORM_TRS(.t = pos, .r = r, .s = size);
|
||||
sim_ent_set_xform(e, xf);
|
||||
@ -331,7 +331,7 @@ internal void test_spawn_entities3(Ent *parent, V2 pos)
|
||||
e->sprite_tint = ColorRed;
|
||||
|
||||
sim_ent_enable_prop(e, SEPROP_SOLID);
|
||||
Quad collider_quad = quad_from_rect(RECT(-0.5, -0.5, 1, 1));
|
||||
Quad collider_quad = quad_from_rect(RectFromScalar(-0.5, -0.5, 1, 1));
|
||||
e->local_collider = collider_from_quad(collider_quad);
|
||||
}
|
||||
}
|
||||
@ -365,7 +365,7 @@ internal void test_spawn_tile(Snapshot *world, V2 world_pos)
|
||||
|
||||
i32 sign_x = (world_pos.x >= 0) - (world_pos.x < 0);
|
||||
i32 sign_y = (world_pos.y >= 0) - (world_pos.y < 0);
|
||||
V2i32 tile_index = V2i32FromXY(world_pos.x * SIM_TILES_PER_UNIT_SQRT, world_pos.y * SIM_TILES_PER_UNIT_SQRT);
|
||||
V2I32 tile_index = V2I32FromXY(world_pos.x * SIM_TILES_PER_UNIT_SQRT, world_pos.y * SIM_TILES_PER_UNIT_SQRT);
|
||||
world_pos.x -= sign_x < 0;
|
||||
world_pos.y -= sign_y < 0;
|
||||
|
||||
@ -389,10 +389,10 @@ internal void test_spawn_tile(Snapshot *world, V2 world_pos)
|
||||
}
|
||||
|
||||
sim_ent_enable_prop(e, SEPROP_SOLID);
|
||||
Quad collider_quad = quad_from_rect(RECT(-tile_size.x / 2, -tile_size.y / 2, tile_size.y, tile_size.y));
|
||||
Quad collider_quad = quad_from_rect(RectFromScalar(-tile_size.x / 2, -tile_size.y / 2, tile_size.y, tile_size.y));
|
||||
e->local_collider = collider_from_quad(collider_quad);
|
||||
#else
|
||||
V2i32 tile_index = sim_world_tile_index_from_pos(world_pos);
|
||||
V2I32 tile_index = sim_world_tile_index_from_pos(world_pos);
|
||||
sim_snapshot_set_tile(world, tile_index, SIM_TILE_KIND_WALL);
|
||||
#endif
|
||||
}
|
||||
@ -467,8 +467,8 @@ internal void test_generate_walls(Snapshot *world)
|
||||
}
|
||||
|
||||
struct wall_node {
|
||||
V2i32 start;
|
||||
V2i32 end;
|
||||
V2I32 start;
|
||||
V2I32 end;
|
||||
i32 wall_dir; /* = 0 up, 1 = right, 2 = down, 3 = left */
|
||||
struct wall_node *next;
|
||||
};
|
||||
@ -483,9 +483,9 @@ internal void test_generate_walls(Snapshot *world)
|
||||
/* Generate horizontal wall nodes */
|
||||
for (u64 sorted_index = 0; sorted_index < sorted_tile_chunks_count; ++sorted_index) {
|
||||
Ent *chunk = x_sorted_tile_chunks[sorted_index];
|
||||
V2i32 chunk_index = chunk->tile_chunk_index;
|
||||
Ent *top_chunk = sim_tile_chunk_from_chunk_index(world, V2i32FromXY(chunk_index.x, chunk_index.y - 1));
|
||||
Ent *bottom_chunk = sim_tile_chunk_from_chunk_index(world, V2i32FromXY(chunk_index.x, chunk_index.y + 1));
|
||||
V2I32 chunk_index = chunk->tile_chunk_index;
|
||||
Ent *top_chunk = sim_tile_chunk_from_chunk_index(world, V2I32FromXY(chunk_index.x, chunk_index.y - 1));
|
||||
Ent *bottom_chunk = sim_tile_chunk_from_chunk_index(world, V2I32FromXY(chunk_index.x, chunk_index.y + 1));
|
||||
/* If there's no chunk below this one, then do an extra iteration (since walls are created at the top of each tile) */
|
||||
i32 y_iterations = SIM_TILES_PER_CHUNK_SQRT + !bottom_chunk->valid;
|
||||
i32 x_iterations = SIM_TILES_PER_CHUNK_SQRT + 1;
|
||||
@ -497,17 +497,17 @@ internal void test_generate_walls(Snapshot *world)
|
||||
i32 desired_wall_dir = -1;
|
||||
TileKind tile = SIM_TILE_KIND_NONE;
|
||||
if (tile_x < SIM_TILES_PER_CHUNK_SQRT && tile_y < SIM_TILES_PER_CHUNK_SQRT) {
|
||||
tile = sim_get_chunk_tile(chunk, V2i32FromXY(tile_x, tile_y));
|
||||
tile = sim_get_chunk_tile(chunk, V2I32FromXY(tile_x, tile_y));
|
||||
}
|
||||
if (tile_x < SIM_TILES_PER_CHUNK_SQRT) {
|
||||
TileKind top_tile = SIM_TILE_KIND_NONE;
|
||||
if (tile_y == 0) {
|
||||
if (top_chunk->valid) {
|
||||
V2i32 top_tile_local_index = V2i32FromXY(tile_x, SIM_TILES_PER_CHUNK_SQRT - 1);
|
||||
V2I32 top_tile_local_index = V2I32FromXY(tile_x, SIM_TILES_PER_CHUNK_SQRT - 1);
|
||||
top_tile = sim_get_chunk_tile(top_chunk, top_tile_local_index);
|
||||
}
|
||||
} else {
|
||||
top_tile = sim_get_chunk_tile(chunk, V2i32FromXY(tile_x, tile_y - 1));
|
||||
top_tile = sim_get_chunk_tile(chunk, V2I32FromXY(tile_x, tile_y - 1));
|
||||
}
|
||||
if (tile == SIM_TILE_KIND_WALL) {
|
||||
/* Process wall tile */
|
||||
@ -524,8 +524,8 @@ internal void test_generate_walls(Snapshot *world)
|
||||
|
||||
/* Stop wall */
|
||||
if (wall_dir >= 0 && desired_wall_dir != wall_dir) {
|
||||
V2i32 start = sim_world_tile_index_from_local_tile_index(chunk_index, V2i32FromXY(wall_start, tile_y));
|
||||
V2i32 end = sim_world_tile_index_from_local_tile_index(chunk_index, V2i32FromXY(wall_end, tile_y));
|
||||
V2I32 start = sim_world_tile_index_from_local_tile_index(chunk_index, V2I32FromXY(wall_start, tile_y));
|
||||
V2I32 end = sim_world_tile_index_from_local_tile_index(chunk_index, V2I32FromXY(wall_end, tile_y));
|
||||
struct wall_node *node = 0;
|
||||
if (wall_start == 0) {
|
||||
u64 start_hash = rand_u64_from_seed(*(u64 *)&start);
|
||||
@ -572,9 +572,9 @@ internal void test_generate_walls(Snapshot *world)
|
||||
/* Generate vertical wall nodes */
|
||||
for (u64 sorted_index = 0; sorted_index < sorted_tile_chunks_count; ++sorted_index) {
|
||||
Ent *chunk = y_sorted_tile_chunks[sorted_index];
|
||||
V2i32 chunk_index = chunk->tile_chunk_index;
|
||||
Ent *left_chunk = sim_tile_chunk_from_chunk_index(world, V2i32FromXY(chunk_index.x - 1, chunk_index.y));
|
||||
Ent *right_chunk = sim_tile_chunk_from_chunk_index(world, V2i32FromXY(chunk_index.x + 1, chunk_index.y));
|
||||
V2I32 chunk_index = chunk->tile_chunk_index;
|
||||
Ent *left_chunk = sim_tile_chunk_from_chunk_index(world, V2I32FromXY(chunk_index.x - 1, chunk_index.y));
|
||||
Ent *right_chunk = sim_tile_chunk_from_chunk_index(world, V2I32FromXY(chunk_index.x + 1, chunk_index.y));
|
||||
/* If there's no chunk to the right of this one, then do an extra iteration (since walls are created on the left of each tile) */
|
||||
i32 y_iterations = SIM_TILES_PER_CHUNK_SQRT + 1;
|
||||
i32 x_iterations = SIM_TILES_PER_CHUNK_SQRT + !right_chunk->valid;
|
||||
@ -586,18 +586,18 @@ internal void test_generate_walls(Snapshot *world)
|
||||
i32 desired_wall_dir = -1;
|
||||
TileKind tile = SIM_TILE_KIND_NONE;
|
||||
if (tile_x < SIM_TILES_PER_CHUNK_SQRT && tile_y < SIM_TILES_PER_CHUNK_SQRT) {
|
||||
tile = sim_get_chunk_tile(chunk, V2i32FromXY(tile_x, tile_y));
|
||||
tile = sim_get_chunk_tile(chunk, V2I32FromXY(tile_x, tile_y));
|
||||
}
|
||||
|
||||
if (tile_y < SIM_TILES_PER_CHUNK_SQRT) {
|
||||
TileKind left_tile = SIM_TILE_KIND_NONE;
|
||||
if (tile_x == 0) {
|
||||
if (left_chunk->valid) {
|
||||
V2i32 left_tile_local_index = V2i32FromXY(SIM_TILES_PER_CHUNK_SQRT - 1, tile_y);
|
||||
V2I32 left_tile_local_index = V2I32FromXY(SIM_TILES_PER_CHUNK_SQRT - 1, tile_y);
|
||||
left_tile = sim_get_chunk_tile(left_chunk, left_tile_local_index);
|
||||
}
|
||||
} else {
|
||||
left_tile = sim_get_chunk_tile(chunk, V2i32FromXY(tile_x - 1, tile_y));
|
||||
left_tile = sim_get_chunk_tile(chunk, V2I32FromXY(tile_x - 1, tile_y));
|
||||
}
|
||||
if (tile == SIM_TILE_KIND_WALL) {
|
||||
/* Process wall tile */
|
||||
@ -614,8 +614,8 @@ internal void test_generate_walls(Snapshot *world)
|
||||
|
||||
/* Stop wall */
|
||||
if (wall_dir >= 0 && desired_wall_dir != wall_dir) {
|
||||
V2i32 start = sim_world_tile_index_from_local_tile_index(chunk_index, V2i32FromXY(tile_x, wall_start));
|
||||
V2i32 end = sim_world_tile_index_from_local_tile_index(chunk_index, V2i32FromXY(tile_x, wall_end));
|
||||
V2I32 start = sim_world_tile_index_from_local_tile_index(chunk_index, V2I32FromXY(tile_x, wall_start));
|
||||
V2I32 end = sim_world_tile_index_from_local_tile_index(chunk_index, V2I32FromXY(tile_x, wall_end));
|
||||
struct wall_node *node = 0;
|
||||
if (wall_start == 0) {
|
||||
u64 start_hash = rand_u64_from_seed(*(u64 *)&start);
|
||||
@ -748,7 +748,7 @@ internal PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, data, step_ctx)
|
||||
/* Create test blood */
|
||||
/* TODO: Remove this */
|
||||
{
|
||||
Xform xf = XFORM_TRS(.t = point, .r = rand_f64_from_state(&step_ctx->rand, 0, TAU));
|
||||
Xform xf = XFORM_TRS(.t = point, .r = rand_f64_from_state(&step_ctx->rand, 0, Tau));
|
||||
Ent *decal = sim_ent_alloc_sync_src(root);
|
||||
decal->sprite = sprite_tag_from_path(LIT("sprite/blood.ase"));
|
||||
decal->sprite_tint = Rgba32F(1, 1, 1, 0.25f);
|
||||
@ -1209,7 +1209,7 @@ void sim_step(SimStepCtx *ctx)
|
||||
V2 sprite_size = v2_div(sheet->frame_size, (f32)PIXELS_PER_UNIT);
|
||||
|
||||
V2 dir = v2_mul_v2(sprite_size, slice.dir);
|
||||
f32 rot = v2_angle(dir) + PI / 2;
|
||||
f32 rot = v2_angle(dir) + Pi / 2;
|
||||
|
||||
Xform xf = XFORM_IDENT;
|
||||
xf = xform_rotated(xf, -rot);
|
||||
@ -1284,7 +1284,7 @@ void sim_step(SimStepCtx *ctx)
|
||||
|
||||
Xform xf = sim_ent_get_local_xform(ent);
|
||||
xf.og = attach_pos;
|
||||
xf = xform_basis_with_rotation_world(xf, v2_angle(attach_dir) + PI / 2);
|
||||
xf = xform_basis_with_rotation_world(xf, v2_angle(attach_dir) + Pi / 2);
|
||||
sim_ent_set_local_xform(ent, xf);
|
||||
}
|
||||
|
||||
@ -1590,7 +1590,7 @@ void sim_step(SimStepCtx *ctx)
|
||||
|
||||
f32 final_hold_angle_btw_ent_and_focus = v2_angle_from_dirs(hold_ent_dir, hold_dir);
|
||||
f32 final_focus_angle_btw_ent_and_hold = math_asin((math_sin(final_hold_angle_btw_ent_and_focus) * hold_ent_len) / focus_ent_len);
|
||||
f32 final_ent_angle_btw_focus_and_hold = PI - (final_focus_angle_btw_ent_and_hold + final_hold_angle_btw_ent_and_focus);
|
||||
f32 final_ent_angle_btw_focus_and_hold = Pi - (final_focus_angle_btw_ent_and_hold + final_hold_angle_btw_ent_and_focus);
|
||||
|
||||
new_angle = math_unwind_angle(v2_angle_from_dirs(V2FromXY(0, -1), v2_sub(focus_pos, ent_pos)) + final_ent_angle_btw_focus_and_hold - forward_hold_angle_offset);
|
||||
}
|
||||
@ -1776,7 +1776,7 @@ void sim_step(SimStepCtx *ctx)
|
||||
}
|
||||
#endif
|
||||
|
||||
Xform xf = XFORM_TRS(.t = pos, .r = v2_angle(vel) + PI / 2);
|
||||
Xform xf = XFORM_TRS(.t = pos, .r = v2_angle(vel) + Pi / 2);
|
||||
sim_ent_set_xform(ent, xf);
|
||||
|
||||
sim_ent_enable_prop(ent, SEPROP_KINEMATIC);
|
||||
|
||||
@ -206,7 +206,7 @@ S_StartupReceipt sprite_startup(void)
|
||||
u32 width = 64;
|
||||
u32 height = 64;
|
||||
u32 *pixels = generate_purple_black_image(scratch.arena, width, height);
|
||||
G.nil_texture->gp_texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, V2i32FromXY(width, height), pixels);
|
||||
G.nil_texture->gp_texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, V2I32FromXY(width, height), pixels);
|
||||
EndScratch(scratch);
|
||||
}
|
||||
|
||||
@ -353,7 +353,7 @@ internal void cache_entry_load_texture(struct cache_ref ref, S_Tag tag)
|
||||
e->texture->height = decoded.height;
|
||||
e->texture->valid = 1;
|
||||
e->texture->loaded = 1;
|
||||
e->texture->gp_texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM_SRGB, 0, V2i32FromXY(decoded.width, decoded.height), decoded.pixels);
|
||||
e->texture->gp_texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM_SRGB, 0, V2I32FromXY(decoded.width, decoded.height), decoded.pixels);
|
||||
/* TODO: Query gpu for more accurate texture size in VRAM */
|
||||
memory_size += (decoded.width * decoded.height) * sizeof(*decoded.pixels);
|
||||
success = 1;
|
||||
@ -530,8 +530,8 @@ internal S_Sheet init_sheet_from_ase_result(Arena *arena, Ase_DecodedSheet ase)
|
||||
f32 height = y2 - y1;
|
||||
|
||||
/* Rect */
|
||||
Rect rect_px = RECT(x1_px, y1_px, width_px, height_px);
|
||||
Rect rect = RECT(x1, y1, width, height);
|
||||
Rect rect_px = RectFromScalar(x1_px, y1_px, width_px, height_px);
|
||||
Rect rect = RectFromScalar(x1, y1, width, height);
|
||||
/* Center */
|
||||
V2 center_px = V2FromXY(x1_px + (width_px * 0.5f), y1_px + (height_px * 0.5f));
|
||||
V2 center = V2FromXY(x1 + (width * 0.5f), y1 + (height * 0.5f));
|
||||
@ -992,7 +992,7 @@ internal void *data_from_tag_internal(S_Scope *scope, S_Tag tag, enum cache_entr
|
||||
/* Spinlock until result is ready */
|
||||
if (await && state != CACHE_ENTRY_STATE_LOADED) {
|
||||
while (Atomic32Fetch(&ref.e->state) != CACHE_ENTRY_STATE_LOADED) {
|
||||
ix_pause();
|
||||
IxPause();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1047,7 +1047,7 @@ S_SheetFrame sprite_sheet_get_frame(S_Sheet *sheet, u32 index)
|
||||
S_SheetFrame res = ZI;
|
||||
res.index = 0;
|
||||
res.duration = 0.1;
|
||||
res.clip = CLIP_ALL;
|
||||
res.clip = ClipAll;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@ -229,7 +229,7 @@ struct user_startup_receipt user_startup(F_StartupReceipt *font_sr,
|
||||
P_RegisterLogCallback(debug_console_log_callback, P_LogLevel_Debug);
|
||||
|
||||
G.window = P_AllocWindow();
|
||||
G.swapchain = gp_swapchain_alloc(G.window, V2i32FromXY(100, 100));
|
||||
G.swapchain = gp_swapchain_alloc(G.window, V2I32FromXY(100, 100));
|
||||
P_ShowWindow(G.window);
|
||||
|
||||
/* Start jobs */
|
||||
@ -270,7 +270,7 @@ internal void debug_draw_xform(Xform xf, u32 color_x, u32 color_y)
|
||||
draw_arrow_ray(G.render_sig, pos, y_ray, thickness, arrowhead_len, color_y);
|
||||
|
||||
//u32 color_quad = Rgba32F(0, 1, 1, 0.3);
|
||||
//Quad quad = quad_from_rect(RECT(0, 0, 1, -1));
|
||||
//Quad quad = quad_from_rect(RectFromScalar(0, 0, 1, -1));
|
||||
//quad = xform_mul_quad(xf, quad_scale(quad, 0.075f));
|
||||
//draw_quad(G.render_sig, quad, color);
|
||||
}
|
||||
@ -846,8 +846,8 @@ internal void user_update(P_Window *window)
|
||||
if (shake > 0) {
|
||||
u64 angle_seed0 = ent->id.uid.lo + (u64)(G.ss_blended->sim_time_ns / frequency_ns);
|
||||
u64 angle_seed1 = angle_seed0 + 1;
|
||||
f32 angle0 = rand_f64_from_seed(angle_seed0, 0, TAU);
|
||||
f32 angle1 = rand_f64_from_seed(angle_seed1, 0, TAU);
|
||||
f32 angle0 = rand_f64_from_seed(angle_seed0, 0, Tau);
|
||||
f32 angle1 = rand_f64_from_seed(angle_seed1, 0, Tau);
|
||||
|
||||
V2 vec0 = v2_with_len(v2_from_angle(angle0), shake);
|
||||
/* NOTE: vec1 not completely accurate since shake can change between frames, it's just a prediction */
|
||||
@ -1031,7 +1031,7 @@ internal void user_update(P_Window *window)
|
||||
V2 size = xform_basis_invert_mul_v2(G.world_to_render_xf, G.render_size);
|
||||
u32 color0 = Rgba32F(0.17f, 0.17f, 0.17f, 1.f);
|
||||
u32 color1 = Rgba32F(0.15f, 0.15f, 0.15f, 1.f);
|
||||
draw_grid(G.render_sig, xform_from_rect(RECT_FROM_V2(pos, size)), color0, color1, Rgba32(0x3f, 0x3f, 0x3f, 0xFF), ColorRed, ColorGreen, thickness, spacing, offset);
|
||||
draw_grid(G.render_sig, xform_from_rect(RectFromV2(pos, size)), color0, color1, Rgba32(0x3f, 0x3f, 0x3f, 0xFF), ColorRed, ColorGreen, thickness, spacing, offset);
|
||||
}
|
||||
|
||||
#if 0
|
||||
@ -1070,7 +1070,7 @@ internal void user_update(P_Window *window)
|
||||
for (u64 entry_index = 0; entry_index < G.tile_cache.num_reserved_entries; ++entry_index) {
|
||||
struct tile_cache_entry *entry = &G.tile_cache.entries[entry_index];
|
||||
if (entry->valid) {
|
||||
V2i32 chunk_pos = entry->pos;
|
||||
V2I32 chunk_pos = entry->pos;
|
||||
Ent *chunk_ent = sim_ent_from_chunk_pos(chunk_pos);
|
||||
if (entry->applied_dirty_gen != chunk_ent->dirty_gen) {
|
||||
entry->applied_dirty_gen = chunk_ent->dirty_gen;
|
||||
@ -1094,7 +1094,7 @@ internal void user_update(P_Window *window)
|
||||
for (u64 entry_index = 0; entry_index < G.tile_cache.num_reserved_entries; ++entry_index) {
|
||||
struct tile_cache_entry *entry = &G.tile_cache.entries[entry_index];
|
||||
if (entry->valid) {
|
||||
V2i32 chunk_pos = entry->pos;
|
||||
V2I32 chunk_pos = entry->pos;
|
||||
Ent *chunk_ent = sim_ent_from_chunk_pos(chunk_pos);
|
||||
if (entry->applied_dirty_gen != chunk_ent->dirty_gen) {
|
||||
entry->applied_dirty_gen = chunk_ent->dirty_gen;
|
||||
@ -1104,14 +1104,14 @@ internal void user_update(P_Window *window)
|
||||
* [L ] X [R ]
|
||||
* [BL] [B] [BR]
|
||||
*/
|
||||
V2i32 chunk_pos_tl = V2i32FromXY(chunk_pos.x - 1, chunk_pos.y - 1);
|
||||
V2i32 chunk_pos_t = V2i32FromXY(chunk_pos.x, chunk_pos.y - 1);
|
||||
V2i32 chunk_pos_tr = V2i32FromXY(chunk_pos.x + 1, chunk_pos.y - 1);
|
||||
V2i32 chunk_pos_l = V2i32FromXY(chunk_pos.x - 1, chunk_pos.y);
|
||||
V2i32 chunk_pos_r = V2i32FromXY(chunk_pos.x + 1, chunk_pos.y);
|
||||
V2i32 chunk_pos_bl = V2i32FromXY(chunk_pos.x - 1, chunk_pos.y + 1);
|
||||
V2i32 chunk_pos_b = V2i32FromXY(chunk_pos.x, chunk_pos.y + 1);
|
||||
V2i32 chunk_pos_br = V2i32FromXY(chunk_pos.x + 1, chunk_pos.y + 1);
|
||||
V2I32 chunk_pos_tl = V2I32FromXY(chunk_pos.x - 1, chunk_pos.y - 1);
|
||||
V2I32 chunk_pos_t = V2I32FromXY(chunk_pos.x, chunk_pos.y - 1);
|
||||
V2I32 chunk_pos_tr = V2I32FromXY(chunk_pos.x + 1, chunk_pos.y - 1);
|
||||
V2I32 chunk_pos_l = V2I32FromXY(chunk_pos.x - 1, chunk_pos.y);
|
||||
V2I32 chunk_pos_r = V2I32FromXY(chunk_pos.x + 1, chunk_pos.y);
|
||||
V2I32 chunk_pos_bl = V2I32FromXY(chunk_pos.x - 1, chunk_pos.y + 1);
|
||||
V2I32 chunk_pos_b = V2I32FromXY(chunk_pos.x, chunk_pos.y + 1);
|
||||
V2I32 chunk_pos_br = V2I32FromXY(chunk_pos.x + 1, chunk_pos.y + 1);
|
||||
Ent *chunk_ent_tl = sim_ent_from_chunk_pos(chunk_pos_tl);
|
||||
Ent *chunk_ent_t = sim_ent_from_chunk_pos(chunk_pos_t);
|
||||
Ent *chunk_ent_tr = sim_ent_from_chunk_pos(chunk_pos_tr);
|
||||
@ -1240,20 +1240,20 @@ internal void user_update(P_Window *window)
|
||||
/* Draw tiles */
|
||||
/* TODO: Something better */
|
||||
if (sim_ent_has_prop(ent, SEPROP_TILE_CHUNK)) {
|
||||
V2i32 chunk_index = ent->tile_chunk_index;
|
||||
V2I32 chunk_index = ent->tile_chunk_index;
|
||||
S_Tag tile_sprite = sprite_tag_from_path(LIT("sprite/tile.ase"));
|
||||
S_Texture *tile_texture = sprite_texture_from_tag_async(sprite_frame_scope, tile_sprite);
|
||||
if (tile_texture->loaded) {
|
||||
f32 tile_size = 1.f / SIM_TILES_PER_UNIT_SQRT;
|
||||
for (i32 tile_y = 0; tile_y < SIM_TILES_PER_CHUNK_SQRT; ++tile_y) {
|
||||
for (i32 tile_x = 0; tile_x < SIM_TILES_PER_CHUNK_SQRT; ++tile_x) {
|
||||
V2i32 local_tile_index = V2i32FromXY(tile_x, tile_y);
|
||||
V2I32 local_tile_index = V2I32FromXY(tile_x, tile_y);
|
||||
TileKind tile = ent->tile_chunk_tiles[local_tile_index.x + (local_tile_index.y * SIM_TILES_PER_CHUNK_SQRT)];
|
||||
//if (tile > -1) {
|
||||
if (tile == SIM_TILE_KIND_WALL) {
|
||||
V2i32 world_tile_index = sim_world_tile_index_from_local_tile_index(chunk_index, local_tile_index);
|
||||
V2I32 world_tile_index = sim_world_tile_index_from_local_tile_index(chunk_index, local_tile_index);
|
||||
V2 pos = sim_pos_from_world_tile_index(world_tile_index);
|
||||
Xform tile_xf = xform_from_rect(RECT_FROM_V2(pos, V2FromXY(tile_size, tile_size)));
|
||||
Xform tile_xf = xform_from_rect(RectFromV2(pos, V2FromXY(tile_size, tile_size)));
|
||||
D_MaterialParams params = DRAW_MATERIAL_PARAMS(.xf = tile_xf, .texture = tile_texture->gp_texture, .is_light = 1, .light_emittance = V3FromXYZ(0, 0, 0));
|
||||
draw_material(G.render_sig, params);
|
||||
}
|
||||
@ -1678,7 +1678,7 @@ internal void user_update(P_Window *window)
|
||||
f32 thickness = 3;
|
||||
|
||||
Xform quad_xf = xform_mul(xf, ent->camera_quad_xform);
|
||||
Quad quad = xform_mul_quad(quad_xf, QUAD_UNIT_SQUARE_CENTERED);
|
||||
Quad quad = xform_mul_quad(quad_xf, QuadUnitSquareCentered);
|
||||
quad = xform_mul_quad(G.world_to_ui_xf, quad);
|
||||
|
||||
draw_quad_line(G.render_sig, quad, thickness, color);
|
||||
@ -1710,7 +1710,7 @@ internal void user_update(P_Window *window)
|
||||
} else {
|
||||
S_Texture *t = sprite_texture_from_tag_async(sprite_frame_scope, sprite_tag_from_path(LIT("sprite/crosshair.ase")));
|
||||
V2 size = V2FromXY(t->width, t->height);
|
||||
Rect cursor_clip = RECT_FROM_V2(G.ui_screen_offset, G.ui_size);
|
||||
Rect cursor_clip = RectFromV2(G.ui_screen_offset, G.ui_size);
|
||||
cursor_clip.pos = v2_add(cursor_clip.pos, v2_mul(size, 0.5f));
|
||||
cursor_clip.pos = v2_add(cursor_clip.pos, V2FromXY(1, 1));
|
||||
cursor_clip.size = v2_sub(cursor_clip.size, size);
|
||||
@ -1975,15 +1975,15 @@ internal void user_update(P_Window *window)
|
||||
text.len += string_format(temp.arena, LIT("cursor world: %F, %F"), FMT_FLOAT(world_cursor.x), FMT_FLOAT(world_cursor.y)).len;
|
||||
text.len += string_copy(temp.arena, LIT("\n")).len;
|
||||
|
||||
V2i32 world_tile_cursor = sim_world_tile_index_from_pos(world_cursor);
|
||||
V2I32 world_tile_cursor = sim_world_tile_index_from_pos(world_cursor);
|
||||
text.len += string_format(temp.arena, LIT("cursor world tile: %F, %F"), FMT_SINT(world_tile_cursor.x), FMT_SINT(world_tile_cursor.y)).len;
|
||||
text.len += string_copy(temp.arena, LIT("\n")).len;
|
||||
|
||||
V2i32 local_tile_cursor = sim_local_tile_index_from_world_tile_index(world_tile_cursor);
|
||||
V2I32 local_tile_cursor = sim_local_tile_index_from_world_tile_index(world_tile_cursor);
|
||||
text.len += string_format(temp.arena, LIT("cursor local tile: %F, %F"), FMT_SINT(local_tile_cursor.x), FMT_SINT(local_tile_cursor.y)).len;
|
||||
text.len += string_copy(temp.arena, LIT("\n")).len;
|
||||
|
||||
V2i32 tile_chunk_cursor = sim_tile_chunk_index_from_world_tile_index(world_tile_cursor);
|
||||
V2I32 tile_chunk_cursor = sim_tile_chunk_index_from_world_tile_index(world_tile_cursor);
|
||||
text.len += string_format(temp.arena, LIT("cursor tile chunk: %F, %F"), FMT_SINT(tile_chunk_cursor.x), FMT_SINT(tile_chunk_cursor.y)).len;
|
||||
text.len += string_copy(temp.arena, LIT("\n")).len;
|
||||
text.len += string_copy(temp.arena, LIT("\n")).len;
|
||||
@ -2052,9 +2052,9 @@ internal void user_update(P_Window *window)
|
||||
|
||||
{
|
||||
__profn("Render");
|
||||
V2i32 world_resolution = v2_round_to_int(G.render_size);
|
||||
V2i32 user_resolution = v2_round_to_int(G.ui_size);
|
||||
V2i32 backbuffer_resolution = v2_round_to_int(G.screen_size);
|
||||
V2I32 world_resolution = v2_round_to_int(G.render_size);
|
||||
V2I32 user_resolution = v2_round_to_int(G.ui_size);
|
||||
V2I32 backbuffer_resolution = v2_round_to_int(G.screen_size);
|
||||
|
||||
/* Draw world to user texture */
|
||||
G_Resource *render_texture = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user