mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 11:17:05 -04:00
Reset models and rotation modes when leaving the world.
fixes #1173 should fix #1167
This commit is contained in:
parent
18dbcc4d4f
commit
2e7372580f
@ -498,6 +498,8 @@ pub fn unloadAssets() void { // MARK: unloadAssets()
|
||||
items_zig.reset();
|
||||
biomes_zig.reset();
|
||||
migrations_zig.reset();
|
||||
main.models.reset();
|
||||
main.rotation.reset();
|
||||
|
||||
// Remove paths from asset hot reloading:
|
||||
var dir = std.fs.cwd().openDir("assets", .{.iterate = true}) catch |err| {
|
||||
|
@ -552,9 +552,13 @@ pub fn init() void {
|
||||
nameToIndex.put("none", Model.init(&.{})) catch unreachable;
|
||||
}
|
||||
|
||||
pub fn uploadModels() void {
|
||||
quadSSBO = graphics.SSBO.initStatic(QuadInfo, quads.items);
|
||||
quadSSBO.bind(4);
|
||||
pub fn reset() void {
|
||||
models.clearRetainingCapacity();
|
||||
quads.clearRetainingCapacity();
|
||||
extraQuadInfos.clearRetainingCapacity();
|
||||
quadDeduplication.clearRetainingCapacity();
|
||||
nameToIndex.clearRetainingCapacity();
|
||||
nameToIndex.put("none", Model.init(&.{})) catch unreachable;
|
||||
}
|
||||
|
||||
pub fn deinit() void {
|
||||
@ -568,3 +572,8 @@ pub fn deinit() void {
|
||||
extraQuadInfos.deinit();
|
||||
quadDeduplication.deinit();
|
||||
}
|
||||
|
||||
pub fn uploadModels() void {
|
||||
quadSSBO = graphics.SSBO.initStatic(QuadInfo, quads.items);
|
||||
quadSSBO.bind(4);
|
||||
}
|
||||
|
@ -144,6 +144,7 @@ pub const RotationModes = struct {
|
||||
pub const id: []const u8 = "no_rotation";
|
||||
fn init() void {}
|
||||
fn deinit() void {}
|
||||
fn reset() void {}
|
||||
};
|
||||
pub const Log = struct { // MARK: Log
|
||||
pub const id: []const u8 = "log";
|
||||
@ -157,6 +158,10 @@ pub const RotationModes = struct {
|
||||
rotatedModels.deinit();
|
||||
}
|
||||
|
||||
fn reset() void {
|
||||
rotatedModels.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
pub fn createBlockModel(zon: ZonElement) u16 {
|
||||
const modelId = zon.as([]const u8, "cubyz:cube");
|
||||
if(rotatedModels.get(modelId)) |modelIndex| return modelIndex;
|
||||
@ -198,6 +203,10 @@ pub const RotationModes = struct {
|
||||
rotatedModels.deinit();
|
||||
}
|
||||
|
||||
fn reset() void {
|
||||
rotatedModels.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
pub fn createBlockModel(zon: ZonElement) u16 {
|
||||
const modelId = zon.as([]const u8, "cubyz:cube");
|
||||
if(rotatedModels.get(modelId)) |modelIndex| return modelIndex;
|
||||
@ -250,6 +259,10 @@ pub const RotationModes = struct {
|
||||
fenceModels.deinit();
|
||||
}
|
||||
|
||||
fn reset() void {
|
||||
fenceModels.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
fn fenceTransform(quad: *main.models.QuadInfo, data: FenceData) void {
|
||||
for(&quad.corners, &quad.cornerUV) |*corner, *cornerUV| {
|
||||
if(!data.isConnectedNegX and corner[0] == 0) {
|
||||
@ -357,6 +370,10 @@ pub const RotationModes = struct {
|
||||
branchModels.deinit();
|
||||
}
|
||||
|
||||
fn reset() void {
|
||||
branchModels.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
fn branchTransform(quad: *main.models.QuadInfo, data: BranchData) void {
|
||||
for(&quad.corners) |*corner| {
|
||||
if((!data.isConnected(Neighbor.dirNegX) and corner[0] == 0) or
|
||||
@ -497,10 +514,11 @@ pub const RotationModes = struct {
|
||||
return stairData & subBlockMask(x, y, z) == 0;
|
||||
}
|
||||
|
||||
fn init() void {
|
||||
fn init() void {}
|
||||
fn deinit() void {}
|
||||
fn reset() void {
|
||||
modelIndex = 0;
|
||||
}
|
||||
fn deinit() void {}
|
||||
|
||||
const GreedyFaceInfo = struct {min: Vec2f, max: Vec2f};
|
||||
fn mergeFaces(faceVisible: [2][2]bool, mem: []GreedyFaceInfo) []GreedyFaceInfo {
|
||||
@ -807,6 +825,10 @@ pub const RotationModes = struct {
|
||||
rotatedModels.deinit();
|
||||
}
|
||||
|
||||
fn reset() void {
|
||||
rotatedModels.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
pub fn createBlockModel(zon: ZonElement) u16 {
|
||||
const baseModelId: []const u8 = zon.get([]const u8, "base", "cubyz:cube");
|
||||
const sideModelId: []const u8 = zon.get([]const u8, "side", "cubyz:cube");
|
||||
@ -980,6 +1002,10 @@ pub const RotationModes = struct {
|
||||
rotatedModels.deinit();
|
||||
}
|
||||
|
||||
fn reset() void {
|
||||
rotatedModels.clearRetainingCapacity();
|
||||
}
|
||||
|
||||
pub fn createBlockModel(zon: ZonElement) u16 {
|
||||
const modelId = zon.as([]const u8, "cubyz:cube");
|
||||
if(rotatedModels.get(modelId)) |modelIndex| return modelIndex;
|
||||
@ -1105,6 +1131,9 @@ pub const RotationModes = struct {
|
||||
|
||||
fn init() void {}
|
||||
fn deinit() void {}
|
||||
fn reset() void {
|
||||
modelCache = null;
|
||||
}
|
||||
|
||||
pub fn createBlockModel(zon: ZonElement) u16 {
|
||||
const modelId = zon.as([]const u8, "cubyz:cube");
|
||||
@ -1168,6 +1197,12 @@ pub fn init() void {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn reset() void {
|
||||
inline for(@typeInfo(RotationModes).@"struct".decls) |declaration| {
|
||||
@field(RotationModes, declaration.name).reset();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deinit() void {
|
||||
rotationModes.deinit();
|
||||
inline for(@typeInfo(RotationModes).@"struct".decls) |declaration| {
|
||||
|
Loading…
x
Reference in New Issue
Block a user