diff --git a/src/base/base_tweak.c b/src/base/base_tweak.c index f90fadf8..f956d685 100644 --- a/src/base/base_tweak.c +++ b/src/base/base_tweak.c @@ -45,7 +45,7 @@ String TweakEx(Arena *arena, TweakVar desc, b32 update_existing) } PushAlign(perm, IsolationSize); SllQueuePushN(bin->first, bin->last, e, next_in_bin); - SllQueuePushN(Base.tweak.first_entry, Base.tweak.last_entry, e, next_in_list); + SllQueuePush(Base.tweak.first_entry, Base.tweak.last_entry, e); Base.tweak.entries_count += 1; } else if (update_existing) @@ -74,7 +74,7 @@ TweakVarArray GetAllTweakVars(Arena *arena) result.count = Base.tweak.entries_count; result.v = PushStructsNoZero(arena, TweakVar, result.count); i64 var_idx = 0; - for (TweakVarEntry *e = Base.tweak.first_entry; e; e = e->next_in_list) + for (TweakVarEntry *e = Base.tweak.first_entry; e; e = e->next) { TweakVar *src = &e->v; TweakVar *dst = &result.v[var_idx]; diff --git a/src/base/base_tweak.h b/src/base/base_tweak.h index 4994cc6b..3aa2f782 100644 --- a/src/base/base_tweak.h +++ b/src/base/base_tweak.h @@ -56,8 +56,8 @@ Struct(TweakFloatDesc) Struct(TweakVarEntry) { + TweakVarEntry *next; TweakVarEntry *next_in_bin; - TweakVarEntry *next_in_list; u64 hash; TweakVar v; }; diff --git a/src/pp/pp_res/tile/Carpet.ase b/src/pp/pp_res/tile/Carpet.ase index 5f82376f..4953e396 100644 --- a/src/pp/pp_res/tile/Carpet.ase +++ b/src/pp/pp_res/tile/Carpet.ase @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a632e9389e35683a1ffca420a6143bbce53648deb77b9bdf4f0b29f2040a8aa7 -size 506 +oid sha256:53c3410a7a9780f1a8f4b6a01586bc3fe2627bf7802eaebb7e90aaea60f86e4d +size 5038 diff --git a/src/pp/pp_res/tile/DarkBrick.ase b/src/pp/pp_res/tile/DarkBrick.ase new file mode 100644 index 00000000..6cc0626f --- /dev/null +++ b/src/pp/pp_res/tile/DarkBrick.ase @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1e595a5e6cd0dfa98572fadc47fd0975bc5371419eecbde9261c0704ebfcccd3 +size 379 diff --git a/src/pp/pp_res/tile/DarkTile.ase b/src/pp/pp_res/tile/DarkTile.ase new file mode 100644 index 00000000..1b97abba --- /dev/null +++ b/src/pp/pp_res/tile/DarkTile.ase @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed9443b91410e36ae35ab1e759fa152a6284fbb87126239be622699cde04830c +size 411 diff --git a/src/pp/pp_res/tile/LightBrick.ase b/src/pp/pp_res/tile/LightBrick.ase new file mode 100644 index 00000000..857a69ca --- /dev/null +++ b/src/pp/pp_res/tile/LightBrick.ase @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7a927d22af2f551c1af01bebbaf4c11d42c5db6f83fb04d09da9405b5e3b6b19 +size 381 diff --git a/src/pp/pp_res/tile/SmallGreenTile.ase b/src/pp/pp_res/tile/SmallGreenTile.ase new file mode 100644 index 00000000..676d9df8 --- /dev/null +++ b/src/pp/pp_res/tile/SmallGreenTile.ase @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cff1e13f52b2525a4bf74e7a2e27cc5c238bbb114088b2a0a2af7e6382159eef +size 364 diff --git a/src/pp/pp_res/tile/SmallPurpleTile.ase b/src/pp/pp_res/tile/SmallPurpleTile.ase new file mode 100644 index 00000000..b8d42f1a --- /dev/null +++ b/src/pp/pp_res/tile/SmallPurpleTile.ase @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5fd6c3ba5d59acb761d81faec4ede0f5623b348d9560bdc05d40e3451ef0c0e2 +size 364 diff --git a/src/pp/pp_res/tile/Test.ase b/src/pp/pp_res/tile/Test.ase new file mode 100644 index 00000000..9130632b --- /dev/null +++ b/src/pp/pp_res/tile/Test.ase @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5ed1d0f1d408fd535e619db8cd67dc61d313c250f03994fd41918fe6f0e0c1a +size 411 diff --git a/src/pp/pp_res/tile/Tile.ase b/src/pp/pp_res/tile/Tile.ase deleted file mode 100644 index 1a10957f..00000000 --- a/src/pp/pp_res/tile/Tile.ase +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f5ecca86cd89d484660ffd4de207d5fec625ba750ec1b4a30bf5724a6ea8635f -size 423 diff --git a/src/pp/pp_shared.cgh b/src/pp/pp_shared.cgh index 67a0418a..b2e3e995 100644 --- a/src/pp/pp_shared.cgh +++ b/src/pp/pp_shared.cgh @@ -29,8 +29,13 @@ Enum(P_MaterialKind) #define P_TilesXList(X) \ X(Empty) \ X(Wall) \ - X(Tile) \ + X(SmallGreenTile) \ + X(SmallPurpleTile) \ + X(DarkTile) \ + X(DarkBrick) \ + X(LightBrick) \ X(Carpet) \ + X(Test) \ /* -------------------- */ //- Tile kinds @@ -47,9 +52,9 @@ Enum(P_TileKind) #define P_PrefabsXList(X) \ X(None, P_PrefabFlag_HideFromEditor) \ - X(Bot, P_PrefabFlag_None) \ X(GuySpawn, P_PrefabFlag_None) \ X(HealthSpawn, P_PrefabFlag_None) \ + X(Bot, P_PrefabFlag_None) \ /* --------------------------------------------------- */ //- Prefab flags diff --git a/src/pp/pp_sim/pp_sim_core.c b/src/pp/pp_sim/pp_sim_core.c index d94616a8..d38eebb3 100644 --- a/src/pp/pp_sim/pp_sim_core.c +++ b/src/pp/pp_sim/pp_sim_core.c @@ -421,29 +421,61 @@ void S_TickForever(WaveLaneCtx *lane) } } + + + + + + + ////////////////////////////// //- Apply bot controls { - f32 move_bias = TweakFloat("Bot movement bias", 0, -1, 1); - f32 move_frequency = TweakFloat("Bot movement frequency", 0, 0, 10); - f32 turn_frequency = TweakFloat("Bot turn frequency", 0, 0, 10); - // b32 bot_movement_enabled = TweakBool("Bot movement enabled", 1); - for (P_Ent *bot = P_FirstEnt(world_frame); !P_IsEntNil(bot); bot = P_NextEnt(bot)) + b32 should_bots_target_player = TweakBool("Swarm bots to player", 1); + if (should_bots_target_player) { - if (bot->is_bot) + P_Ent *target_player = &P_NilEnt; + for (P_Ent *player = P_FirstEnt(world_frame); !P_IsEntNil(player); player = P_NextEnt(player)) { - i64 alive_time_ns = world_frame->time_ns - bot->created_at_ns; - f64 alive_time = SecondsFromNs(alive_time_ns); - // i64 frequency_ns = NsFromSeconds(0.1); - // bot->control.move.y = SinF32((f64)alive_time_ns / (f64)frequency_ns); + if (player->is_player && !player->is_bot) + { + target_player = player; + break; + } + } + P_Ent *target_guy = P_EntFromKey(world_frame, target_player->guy); + if (target_guy->is_guy) + { + u64 bots_count = 0; + for (P_Ent *bot = P_FirstEnt(world_frame); !P_IsEntNil(bot); bot = P_NextEnt(bot)) + { + if (bot->is_bot) + { + bots_count += 1; + } + } - f32 move_t = alive_time * move_frequency * Tau; - f32 look_t = alive_time * turn_frequency * Tau; - - bot->control.move.y = SinF32(move_t); - bot->control.move.y += move_bias; - bot->control.look = MulVec2(VEC2(CosF32(look_t), SinF32(look_t)), 3); + { + u64 bot_idx = 0; + f32 spacing_len = 2; + for (P_Ent *bot = P_FirstEnt(world_frame); !P_IsEntNil(bot); bot = P_NextEnt(bot)) + { + if (bot->is_bot) + { + f32 radius_ratio = (f32)bot_idx / (f32)bots_count; + Vec2 spacing = MulVec2(Vec2FromAngle(radius_ratio * Tau), spacing_len); + Vec2 target_pos = AddVec2(target_guy->xf.t, spacing); + { + P_Ent *bot_guy = P_EntFromKey(world_frame, bot->guy); + Vec2 dir_to_target = SubVec2(target_pos, bot_guy->xf.t); + bot->control.move = dir_to_target; + bot->control.look = dir_to_target; + } + bot_idx += 1; + } + } + } } } } @@ -453,6 +485,39 @@ void S_TickForever(WaveLaneCtx *lane) + + // ////////////////////////////// + // //- Apply bot controls + + // { + // f32 move_bias = TweakFloat("Bot movement bias", 0, -1, 1); + // f32 move_frequency = TweakFloat("Bot movement frequency", 0, 0, 10); + // f32 turn_frequency = TweakFloat("Bot turn frequency", 0, 0, 10); + // // b32 bot_movement_enabled = TweakBool("Bot movement enabled", 1); + // for (P_Ent *bot = P_FirstEnt(world_frame); !P_IsEntNil(bot); bot = P_NextEnt(bot)) + // { + // if (bot->is_bot) + // { + // i64 alive_time_ns = world_frame->time_ns - bot->created_at_ns; + // f64 alive_time = SecondsFromNs(alive_time_ns); + // // i64 frequency_ns = NsFromSeconds(0.1); + // // bot->control.move.y = SinF32((f64)alive_time_ns / (f64)frequency_ns); + + // f32 move_t = alive_time * move_frequency * Tau; + // f32 look_t = alive_time * turn_frequency * Tau; + + // bot->control.move.y = SinF32(move_t); + // bot->control.move.y += move_bias; + // bot->control.look = MulVec2(VEC2(CosF32(look_t), SinF32(look_t)), 3); + // } + // } + // } + + + + + + ////////////////////////////// //- Process connection messages @@ -544,7 +609,7 @@ void S_TickForever(WaveLaneCtx *lane) // FIXME: Only accept edits from privileged users { - u32 bots_count = 0; + u64 bots_count = 0; b32 should_save = 0; for (P_MsgNode *msg_node = in_msgs.first; msg_node; msg_node = msg_node->next) { diff --git a/src/pp/pp_terms.h b/src/pp/pp_terms.h index 11150d0e..8d3ec0af 100644 --- a/src/pp/pp_terms.h +++ b/src/pp/pp_terms.h @@ -52,30 +52,30 @@ PERSIST Readonly String P_PresetHumanNames[] = { // Taken from a random GMOD server PERSIST Readonly String P_PresetPlayerNames[] = { + CompLit("Tidunbly"), + CompLit("lowayo"), + CompLit("_Runne_"), CompLit("lionberg"), CompLit("charlie main"), + CompLit("Fr0stie"), + CompLit("Mr. Bones"), + CompLit("Legs"), + CompLit("Poy"), CompLit("frezh"), - CompLit("KARMA"), CompLit("Kirep"), CompLit("Cyan Crayon"), CompLit("THE WIFE"), CompLit("Panda"), + CompLit("KARMA"), CompLit("adoti"), CompLit("yoyota"), - CompLit("Mr. Bones"), CompLit("TaurusJ3"), CompLit("dub"), - CompLit("Tidunbly"), CompLit("Siepter"), - CompLit("lowayo"), CompLit("Zunix"), - CompLit("_Runne_"), - CompLit("Fr0stie"), CompLit("Lumby"), - CompLit("Legs"), CompLit("Talids"), CompLit("Train"), - CompLit("Poy"), CompLit("Kaitsedd"), CompLit("jiyu"), }; diff --git a/src/pp/pp_vis/pp_vis_core.c b/src/pp/pp_vis/pp_vis_core.c index 240f9756..b688aeb7 100644 --- a/src/pp/pp_vis/pp_vis_core.c +++ b/src/pp/pp_vis/pp_vis_core.c @@ -7995,12 +7995,13 @@ void V_TickForever(WaveLaneCtx *lane) String sheet_name = StringF(frame->arena, "tile/%F.ase", FmtString(tile_name)); ResourceKey sheet_resource = ResourceKeyFromStore(&P_Resources, sheet_name); SPR_SheetKey sheet = SPR_SheetKeyFromResource(sheet_resource); - tile_sprite = SPR_SpriteFromSheet(sheet, SPR_NilSpanKey, 0); + // Don't use atlas for tile so that we can easily wrap samples + tile_sprite = SPR_SpriteFromSheetEx(sheet, SPR_NilSpanKey, 0, SPR_SheetFlag_NoAtlas); } V_TileDesc tile_desc = Zi; { tile_desc.tex = tile_sprite.tex; - tile_desc.tex_slice_uv = DivRng2Vec2(tile_sprite.tex_rect, tile_sprite.tex_dims); + tile_desc.tex_dims = tile_sprite.tex_dims; } frame->tile_descs[tile_kind] = tile_desc; } diff --git a/src/pp/pp_vis/pp_vis_gpu.g b/src/pp/pp_vis/pp_vis_gpu.g index 19235c3e..608656ac 100644 --- a/src/pp/pp_vis/pp_vis_gpu.g +++ b/src/pp/pp_vis/pp_vis_gpu.g @@ -796,6 +796,7 @@ ComputeShader(V_CompositeCS) // Texture2D shade_tex = G_Deref(frame.shade, Texture2D); SamplerState point_sampler = G_Deref(frame.basic_samplers[G_BasicSamplerKind_PointClamp], SamplerState); SamplerState bilinear_sampler = G_Deref(frame.basic_samplers[G_BasicSamplerKind_BilinearClamp], SamplerState); + SamplerState tile_sampler = G_Deref(frame.basic_samplers[G_BasicSamplerKind_PointWrap], SamplerState); Texture2D albedo_tex = G_Deref(frame.albedo, Texture2D); RWTexture2D screen_tex = G_Deref(frame.screen, RWTexture2D); Texture2D stains = G_Deref(frame.stains, Texture2D); @@ -880,6 +881,7 @@ ComputeShader(V_CompositeCS) // TODO: Remove this b32 tile_is_wall = 0; + b32 tile_is_empty = 0; Vec4 tile_color = 0; { P_TileKind tile_tl = tiles[Vec2(tile_pos.x - 0.99, tile_pos.y - 0.99)]; @@ -904,8 +906,10 @@ ComputeShader(V_CompositeCS) if (tile == P_TileKind_Wall) { - Vec4 outer = LinearFromSrgb(Vec4(0.05, 0.05, 0.05, 1)); - Vec4 inner = LinearFromSrgb(Vec4(0.15, 0.15, 0.15, 1)); + // Vec4 outer = LinearFromSrgb(Vec4(0.05, 0.05, 0.05, 1)); + // Vec4 inner = LinearFromSrgb(Vec4(0.15, 0.15, 0.15, 1)); + Vec4 outer = LinearFromSrgb(Vec4(0.15, 0.15, 0.15, 1)); + Vec4 inner = LinearFromSrgb(Vec4(0.20, 0.20, 0.20, 1)); tile_color = lerp(outer, inner, smoothstep(0, 1, tile_edge_dist / 0.375)); tile_is_wall = 1; } @@ -913,9 +917,12 @@ ComputeShader(V_CompositeCS) { V_TileDesc tile_desc = frame.tile_descs[tile]; Texture2D tile_tex = G_Deref(tile_desc.tex, Texture2D); - Vec2 samp_t = clamp(frac(world_pos), 0.00001, 1.0 - 0.00001); - Vec2 samp_uv = lerp(tile_desc.tex_slice_uv.p0, tile_desc.tex_slice_uv.p1, samp_t); - tile_color = tile_tex.SampleLevel(point_sampler, samp_uv, 0); + Vec2 samp_uv = world_pos * (Vec2(P_CellsPerMeter, P_CellsPerMeter) / tile_desc.tex_dims); + tile_color = tile_tex.SampleLevel(tile_sampler, samp_uv, 0); + } + else + { + tile_is_empty = 1; } } @@ -1042,8 +1049,24 @@ ComputeShader(V_CompositeCS) + ////////////////////////////// + //- Shadow + Vec4 shadow_color = 0; + if (!tile_is_wall && !tile_is_empty) + { + // TODO: Move this to a frame var + f32 shadow_size = 0.05; + Vec2 tile_shadow_pos = mul(frame.af.world_to_tile, Vec3(world_pos.xy - Vec2(shadow_size, shadow_size), 1)); + b32 is_in_shadow = 0; + P_TileKind shadow_tile = tiles[tile_shadow_pos]; + is_in_shadow = shadow_tile == P_TileKind_Wall; + if (is_in_shadow) + { + shadow_color = Vec4(0, 0, 0, 0.75); + } + } ////////////////////////////// //- Compose world @@ -1056,6 +1079,13 @@ ComputeShader(V_CompositeCS) world_color = BlendPremul(tile_color, world_color); // Blend ground tile world_color = BlendPremul(stain_color, world_color); // Blend ground stain world_color = BlendPremul(ground_particle_color, world_color); // Blend ground particle + + // TODO: Blend shadows over tex? + world_color = BlendPremul(shadow_color, world_color); // Blend shadow + // if (shadow_color.a != 0) + // { + // world_color.rgb *= 0.5; // Blend shadow + // } } world_color = BlendPremul(albedo_tex_color, world_color); if (tile_is_wall) diff --git a/src/pp/pp_vis/pp_vis_shared.cgh b/src/pp/pp_vis/pp_vis_shared.cgh index 70c23d68..cf034c6b 100644 --- a/src/pp/pp_vis/pp_vis_shared.cgh +++ b/src/pp/pp_vis/pp_vis_shared.cgh @@ -317,7 +317,7 @@ Struct(V_ProfilerFrame) Struct(V_TileDesc) { G_TextureRef tex; - Rng2 tex_slice_uv; + Vec2 tex_dims; }; Enum(V_SelectionMode)