fix out of bounds tile placement snapping
This commit is contained in:
parent
4bc6a26c74
commit
4b61ac219d
@ -631,9 +631,9 @@ void S_TickForever(WaveLaneCtx *lane)
|
||||
{
|
||||
P_TileKind tile = msg->tile_kind;
|
||||
Rng2I32 range = msg->tile_range;
|
||||
for (i32 tile_y = range.p0.y; tile_y < range.p1.y; ++tile_y)
|
||||
for (i32 tile_y = MaxI32(range.p0.y, 0); tile_y < MinI32(range.p1.y, P_TilesPitch); ++tile_y)
|
||||
{
|
||||
for (i32 tile_x = range.p0.x; tile_x < range.p1.x; ++tile_x)
|
||||
for (i32 tile_x = MaxI32(range.p0.x, 0); tile_x < MinI32(range.p1.x, P_TilesPitch); ++tile_x)
|
||||
{
|
||||
Vec2 tile_pos = VEC2(tile_x, tile_y);
|
||||
i32 tile_idx = P_TileIdxFromTilePos(tile_pos);
|
||||
|
||||
@ -64,6 +64,7 @@ String P_PackWorld(Arena *arena, P_World *src_world)
|
||||
result.len += StringF(arena, " angle: \"%F\"\n", FmtFloat(AngleFromVec2(ent->xf.r))).len;
|
||||
result.len += StringF(arena, " exists: \"%F\"\n", FmtFloat(ent->exists)).len;
|
||||
result.len += StringF(arena, " look: \"%F\"\n", FmtFloat2(ent->control.look)).len;
|
||||
result.len += StringF(arena, " health: \"%F\"\n", FmtFloat(ent->health)).len;
|
||||
}
|
||||
result.len += PushString(arena, Lit(" }\n")).len;
|
||||
}
|
||||
@ -162,8 +163,7 @@ P_UnpackedWorld P_UnpackWorld(Arena *arena, String packed)
|
||||
}
|
||||
if (MatchString(attr->name, Lit("pos")))
|
||||
{
|
||||
Vec2 pos = CR_Vec2FromString(attr->value);
|
||||
ent->xf.t = pos;
|
||||
ent->xf.t = CR_Vec2FromString(attr->value);
|
||||
}
|
||||
if (MatchString(attr->name, Lit("angle")))
|
||||
{
|
||||
@ -179,8 +179,11 @@ P_UnpackedWorld P_UnpackWorld(Arena *arena, String packed)
|
||||
}
|
||||
if (MatchString(attr->name, Lit("look")))
|
||||
{
|
||||
Vec2 look = CR_Vec2FromString(attr->value);
|
||||
ent->control.look = look;
|
||||
ent->control.look = CR_Vec2FromString(attr->value);
|
||||
}
|
||||
if (MatchString(attr->name, Lit("health")))
|
||||
{
|
||||
ent->health = CR_FloatFromString(attr->value);;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1975,7 +1975,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
frame->shade_cursor = MulAffineVec2(frame->af.screen_to_shade, frame->screen_cursor);
|
||||
frame->world_cursor = MulAffineVec2(frame->af.screen_to_world, frame->screen_cursor);
|
||||
|
||||
b32 show_editor_ui = TweakBool("Show editor UI", 0);
|
||||
b32 show_editor_ui = TweakBool("Show editor UI", 1);
|
||||
|
||||
frame->world_selection_start = frame->world_cursor;
|
||||
if (frame->is_editing)
|
||||
@ -2018,11 +2018,13 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
{
|
||||
if (prev_frame->selection_mode == V_SelectionMode_Tile)
|
||||
{
|
||||
// TODO: Fix clamp when both start & end are outside of world
|
||||
Rng2I32 tile_range = Zi;
|
||||
{
|
||||
tile_range.p0 = Vec2I32FromVec(FloorVec2(MulAffineVec2(frame->af.world_to_tile, prev_frame->world_selection.p0)));
|
||||
tile_range.p1 = Vec2I32FromVec(CeilVec2(MulAffineVec2(frame->af.world_to_tile, prev_frame->world_selection.p1)));
|
||||
|
||||
tile_range.p1.x = MaxI32(tile_range.p1.x, tile_range.p0.x + 1);
|
||||
tile_range.p1.y = MaxI32(tile_range.p1.y, tile_range.p0.y + 1);
|
||||
}
|
||||
P_Msg *msg = P_PushMsg(P_MsgKind_TileEdit, Zstr);
|
||||
msg->tile_kind = prev_frame->equipped_tile;
|
||||
msg->tile_range = tile_range;
|
||||
|
||||
@ -535,6 +535,7 @@ PixelShader(V_CompositePS, V_CompositePSOutput, V_CompositePSInput input)
|
||||
Rng2 tile_selection;
|
||||
tile_selection.p0 = floor(mul(frame.af.world_to_tile, Vec3(world_selection.p0, 1)));
|
||||
tile_selection.p1 = ceil(mul(frame.af.world_to_tile, Vec3(world_selection.p1, 1)));
|
||||
tile_selection.p1 = max(tile_selection.p1, tile_selection.p0 + 1);
|
||||
|
||||
f32 dist = 100000000;
|
||||
dist = min(dist, screen_pos.x - screen_selection.p0.x);
|
||||
@ -550,10 +551,6 @@ PixelShader(V_CompositePS, V_CompositePSOutput, V_CompositePSInput input)
|
||||
// else
|
||||
{
|
||||
if (
|
||||
world_pos.x > -(P_WorldPitch / 2) &&
|
||||
world_pos.y > -(P_WorldPitch / 2) &&
|
||||
world_pos.x < (P_WorldPitch / 2) &&
|
||||
world_pos.y < (P_WorldPitch / 2) &&
|
||||
tile_pos.x >= tile_selection.p0.x &&
|
||||
tile_pos.x <= tile_selection.p1.x &&
|
||||
tile_pos.y >= tile_selection.p0.y &&
|
||||
|
||||
Loading…
Reference in New Issue
Block a user