From 0f64806045396a9f2c8fe2ccab6a4e7aac11a1b2 Mon Sep 17 00:00:00 2001 From: Louis Pearson Date: Sun, 23 Jan 2022 16:13:08 -0700 Subject: [PATCH] Only draw wires on screen --- src/main.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.zig b/src/main.zig index 536c34e..03e1e6b 100644 --- a/src/main.zig +++ b/src/main.zig @@ -500,6 +500,7 @@ fn updateCircuit() void { fn wirePhysicsProcess(dt: f32, wire: *Wire) void { var nodes = wire.nodes.slice(); if (nodes.len == 0) return; + if (!inView(wire.begin().pos) or !inView(wire.end().pos)) return; var physics = Physics{ .gravity = Vec2f{ 0, 0.25 }, .friction = Vec2f{ 0.1, 0.1 } }; var kinematic = Kinematic{ .col = AABB{ .pos = Vec2f{ -1, -1 }, .size = Vec2f{ 1, 1 } } }; @@ -550,6 +551,7 @@ fn constrainNodes(prevNode: *Pos, node: *Pos) void { } fn wireDrawProcess(_: f32, wire: *Wire) void { + if (!inView(wire.begin().pos) or !inView(wire.end().pos)) return; var nodes = wire.nodes.slice(); if (nodes.len == 0) return; @@ -570,6 +572,7 @@ fn vec2ftovec2(vec2f: Vec2f) w4.Vec2 { } fn drawProcess(_: f32, pos: *Pos, sprite: *Sprite) void { + if (!inView(pos.pos)) return; w4.DRAW_COLORS.* = 0x2210; const fpos = pos.pos + sprite.offset; const ipos = w4.Vec2{ @floatToInt(i32, fpos[0]), @floatToInt(i32, fpos[1]) } - camera * Map.tile_size;