Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/game.zig
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ pub fn pressBreak(_: main.Window.Key.Modifiers) void {
}

pub fn releaseBreak(_: main.Window.Key.Modifiers) void {
main.renderer.MeshSelection.stopBreakBlock(main.renderer.MeshSelection.lastSelectedBlockPos);
nextBlockBreakTime = null;
}

Expand Down
9 changes: 7 additions & 2 deletions src/renderer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ pub const MeshSelection = struct { // MARK: MeshSelection
var posBeforeBlock: Vec3i = undefined;
var neighborOfSelection: chunk.Neighbor = undefined;
pub var selectedBlockPos: ?Vec3i = null;
var lastSelectedBlockPos: Vec3i = undefined;
pub var lastSelectedBlockPos: Vec3i = undefined;
var currentBlockProgress: f32 = 0;
var currentSwingProgress: f32 = 0;
var currentSwingTime: f32 = 0;
Expand Down Expand Up @@ -1036,7 +1036,12 @@ pub const MeshSelection = struct { // MARK: MeshSelection
}
}
}

pub fn stopBreakBlock(pos: Vec3i) void {
if(@reduce(.And, lastSelectedBlockPos == pos)) {
mesh_storage.removeBreakingAnimation(lastSelectedBlockPos);
currentBlockProgress = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look for a solution that keeps the breaking progress of the block when you release the button.

Also note that in the future we would want to support multiple block breaking animations from multiple players, synchronized through the server.

}
}
pub fn breakBlock(inventory: main.items.Inventory, slot: u32, deltaTime: f64) void {
if(selectedBlockPos) |selectedPos| {
const stack = inventory.getStack(slot);
Expand Down
1 change: 1 addition & 0 deletions src/renderer/mesh_storage.zig
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,7 @@ pub const MeshGenerationTask = struct { // MARK: MeshGenerationTask
// MARK: updaters

pub fn updateBlock(update: BlockUpdate) void {
main.renderer.MeshSelection.stopBreakBlock(.{update.x, update.y, update.z});
blockUpdateList.pushBack(BlockUpdate.initManaged(main.globalAllocator, update));
}

Expand Down