Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
scallyw4g committed Apr 2, 2024
2 parents 00ba4c5 + 687125c commit de4f4fe
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 30 deletions.
2 changes: 1 addition & 1 deletion examples/turn_based/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ GameEntityUpdate(engine_resources *Engine, entity *Entity )
{
v3 EntitySimP = GetSimSpaceBaseP(World, Entity);

r32 AnimOffset = Sin(fmodf(Plat->GameTime*2.f, PI32*2.f)) + 3.f;
r32 AnimOffset = Sin(Mod(Plat->GameTime*2.f, PI32*2.f)) + 3.f;
v3 NewP = EntitySimP + V3(0.f, 0.f, Entity->_CollisionVolumeRadius.z*2.f + AnimOffset) - V3(Carrying->_CollisionVolumeRadius.xy, 0.f);

Carrying->P = SimSpaceToCanonical(World, NewP);
Expand Down
2 changes: 1 addition & 1 deletion external/bonsai_stdlib
2 changes: 1 addition & 1 deletion generated/gen_common_vector_v2.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/vector.h:750:0
// external/bonsai_stdlib/src/vector.h:742:0

inline r32
LengthSq( v2 Vec )
Expand Down
2 changes: 1 addition & 1 deletion generated/gen_common_vector_v3.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/vector.h:753:0
// external/bonsai_stdlib/src/vector.h:745:0

inline r32
LengthSq( v3 Vec )
Expand Down
2 changes: 1 addition & 1 deletion generated/gen_common_vector_v3i.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/vector.h:756:0
// external/bonsai_stdlib/src/vector.h:748:0

inline s32
LengthSq( v3i Vec )
Expand Down
2 changes: 1 addition & 1 deletion generated/gen_lerp_f32.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/vector.h:730:0
// external/bonsai_stdlib/src/vector.h:722:0

inline f32
Lerp(r32 t, f32 P1, f32 P2)
Expand Down
2 changes: 1 addition & 1 deletion generated/gen_lerp_v2.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/vector.h:733:0
// external/bonsai_stdlib/src/vector.h:725:0

inline v2
Lerp(r32 t, v2 P1, v2 P2)
Expand Down
2 changes: 1 addition & 1 deletion generated/gen_lerp_v3.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/vector.h:736:0
// external/bonsai_stdlib/src/vector.h:728:0

inline v3
Lerp(r32 t, v3 P1, v3 P2)
Expand Down
2 changes: 1 addition & 1 deletion generated/gen_vector_area_v2.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/vector.h:744:0
// external/bonsai_stdlib/src/vector.h:736:0

inline r32
Area( v2 Vec )
Expand Down
2 changes: 1 addition & 1 deletion generated/gen_vector_area_v2i.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/vector.h:747:0
// external/bonsai_stdlib/src/vector.h:739:0

inline s32
Area( v2i Vec )
Expand Down
2 changes: 1 addition & 1 deletion generated/gen_vector_infix_operator_v3i_688856393.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/vector.h:727:0
// external/bonsai_stdlib/src/vector.h:719:0

inline v3i
operator&( v3i P1, v3i P2 )
Expand Down
2 changes: 1 addition & 1 deletion generated/gen_vector_infix_operator_v3i_688856449.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/vector.h:724:0
// external/bonsai_stdlib/src/vector.h:716:0

inline v3i
operator^( v3i P1, v3i P2 )
Expand Down
2 changes: 1 addition & 1 deletion generated/gen_vector_normalize_funcs_v2.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/vector.h:759:0
// external/bonsai_stdlib/src/vector.h:751:0

inline v2
Normalize( v2 Vec, r32 Length)
Expand Down
2 changes: 1 addition & 1 deletion generated/gen_vector_normalize_funcs_v3.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/vector.h:762:0
// external/bonsai_stdlib/src/vector.h:754:0

inline v3
Normalize( v3 Vec, r32 Length)
Expand Down
2 changes: 1 addition & 1 deletion generated/scalar_math_fuctions_451039071.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// external/bonsai_stdlib/src/math.h:323:0
// external/bonsai_stdlib/src/math.h:301:0

inline r32
Clamp( r32 Min, r32 Value, r32 Max )
Expand Down
22 changes: 11 additions & 11 deletions jesse.make.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/usr/bin/env bash

OPT="-O2"
# OPT="-O2"

./make.sh RunPoof
[ $? -ne 0 ] && exit 1
# ./make.sh RunPoof
# [ $? -ne 0 ] && exit 1

./make.sh $OPT BuildAll
# ./make.sh $OPT BuildAll

# ./make.sh $OPT \
# BuildSingleExample examples/blank_project \
# BuildSingleExample examples/project_and_level_picker \
# BuildSingleExample examples/terrain_gen \
# BuildExecutables \
# BuildDebugSystem \
# BuildSingleExample examples/turn_based \
./make.sh $OPT \
BuildSingleExample examples/blank_project \
BuildExecutables \
BuildDebugSystem \
BuildSingleExample examples/terrain_gen \
BuildSingleExample examples/project_and_level_picker \
BuildSingleExample examples/turn_based \
# BuildSingleExample examples/tools/voxel_synthesis_rule_baker \
# BuildSingleExample examples/the_wanderer \
# BuildSingleExample examples/graveyard \
Expand Down
38 changes: 38 additions & 0 deletions make_transcendental_tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#! /bin/python

# Generates arrays of pre-calculated cosine & arccosine values as literals for C.

from math import acos, cos, pi

def gen_cos_table(f, PRECISION, NAME, math_func):
f.write("global_variable f32 %s[] = {\n" % NAME)
j = 0
p = 0.0
while True:
f.write("{:.10f}f, ".format(math_func(p)))
j += 1
if j % 16 == 0:
f.write("\n")
p += PRECISION
if p > 2*pi:
break
f.write("1.f, 1.f };// NOTE(Jesse): Add a duplicate for the max value so we can blindly add 1 to the lookup index and not overflow (to lerp)\n")

def gen_acos_table(f, PRECISION, NAME, math_func):
f.write("global_variable f32 %s[] = {\n" % NAME)
j = 0
p = -1.0
while True:
f.write("{:.10f}f, ".format(math_func(p)))
j += 1
if j % 16 == 0:
f.write("\n")
p += PRECISION
if p > 1.0:
break
f.write("0.f, 0.f }; // NOTE(Jesse): Add a duplicate for the max value so we can blindly add 1 to the lookup index and not overflow (to lerp)\n")


if __name__ == '__main__':
gen_cos_table(open("external/bonsai_stdlib/src/costable.h", "w"), 0.0001, "CosineTable", cos)
gen_acos_table(open("external/bonsai_stdlib/src/arccostable.h", "w"), 0.0001, "ArcCosineTable", acos)
13 changes: 9 additions & 4 deletions src/engine/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@ Bonsai_Simulate(engine_resources *Resources)
if (CameraGhost) { CameraTargetP = CameraGhost->P; }

b32 DoPositionDelta = (!UiCapturedMouseInput(Ui) && UiInteractionWasViewport(Ui));
b32 DoZoomDelta = DoPositionDelta; //UiHoveredMouseInput(Ui) == False;

// NOTE(Jesse): Don't remember what bug I fixed by changing this to DoPositionDelta,
// but it broke scrolling on laptop trackpads (where nothing is clicked). Going to
// remove it until I remember what the bug was ..
/* b32 DoZoomDelta = DoPositionDelta; */
b32 DoZoomDelta = UiHoveredMouseInput(Ui) == False;

v2 MouseDelta = GetMouseDelta(Plat);
UpdateGameCamera(World, MouseDelta, InputForCamera, CameraTargetP, Camera, Plat->dt, DoPositionDelta, DoZoomDelta);
Expand Down Expand Up @@ -389,9 +394,9 @@ Bonsai_Render(engine_resources *Resources)
if (CameraGhost)
{
v3 CameraTargetSimP = GetSimSpaceP(World, CameraGhost);
Graphics->Settings.OffsetOfWorldCenterToGrid.x = fmodf(CameraTargetSimP.x, Graphics->Settings.MajorGridDim);
Graphics->Settings.OffsetOfWorldCenterToGrid.y = fmodf(CameraTargetSimP.y, Graphics->Settings.MajorGridDim);
Graphics->Settings.OffsetOfWorldCenterToGrid.z = fmodf(CameraTargetSimP.z, Graphics->Settings.MajorGridDim);
Graphics->Settings.OffsetOfWorldCenterToGrid.x = Mod(CameraTargetSimP.x, Graphics->Settings.MajorGridDim);
Graphics->Settings.OffsetOfWorldCenterToGrid.y = Mod(CameraTargetSimP.y, Graphics->Settings.MajorGridDim);
Graphics->Settings.OffsetOfWorldCenterToGrid.z = Mod(CameraTargetSimP.z, Graphics->Settings.MajorGridDim);
}
#endif

Expand Down

0 comments on commit de4f4fe

Please sign in to comment.