mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 19:28:49 -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();
|
items_zig.reset();
|
||||||
biomes_zig.reset();
|
biomes_zig.reset();
|
||||||
migrations_zig.reset();
|
migrations_zig.reset();
|
||||||
|
main.models.reset();
|
||||||
|
main.rotation.reset();
|
||||||
|
|
||||||
// Remove paths from asset hot reloading:
|
// Remove paths from asset hot reloading:
|
||||||
var dir = std.fs.cwd().openDir("assets", .{.iterate = true}) catch |err| {
|
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;
|
nameToIndex.put("none", Model.init(&.{})) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uploadModels() void {
|
pub fn reset() void {
|
||||||
quadSSBO = graphics.SSBO.initStatic(QuadInfo, quads.items);
|
models.clearRetainingCapacity();
|
||||||
quadSSBO.bind(4);
|
quads.clearRetainingCapacity();
|
||||||
|
extraQuadInfos.clearRetainingCapacity();
|
||||||
|
quadDeduplication.clearRetainingCapacity();
|
||||||
|
nameToIndex.clearRetainingCapacity();
|
||||||
|
nameToIndex.put("none", Model.init(&.{})) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit() void {
|
pub fn deinit() void {
|
||||||
@ -568,3 +572,8 @@ pub fn deinit() void {
|
|||||||
extraQuadInfos.deinit();
|
extraQuadInfos.deinit();
|
||||||
quadDeduplication.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";
|
pub const id: []const u8 = "no_rotation";
|
||||||
fn init() void {}
|
fn init() void {}
|
||||||
fn deinit() void {}
|
fn deinit() void {}
|
||||||
|
fn reset() void {}
|
||||||
};
|
};
|
||||||
pub const Log = struct { // MARK: Log
|
pub const Log = struct { // MARK: Log
|
||||||
pub const id: []const u8 = "log";
|
pub const id: []const u8 = "log";
|
||||||
@ -157,6 +158,10 @@ pub const RotationModes = struct {
|
|||||||
rotatedModels.deinit();
|
rotatedModels.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reset() void {
|
||||||
|
rotatedModels.clearRetainingCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn createBlockModel(zon: ZonElement) u16 {
|
pub fn createBlockModel(zon: ZonElement) u16 {
|
||||||
const modelId = zon.as([]const u8, "cubyz:cube");
|
const modelId = zon.as([]const u8, "cubyz:cube");
|
||||||
if(rotatedModels.get(modelId)) |modelIndex| return modelIndex;
|
if(rotatedModels.get(modelId)) |modelIndex| return modelIndex;
|
||||||
@ -198,6 +203,10 @@ pub const RotationModes = struct {
|
|||||||
rotatedModels.deinit();
|
rotatedModels.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reset() void {
|
||||||
|
rotatedModels.clearRetainingCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn createBlockModel(zon: ZonElement) u16 {
|
pub fn createBlockModel(zon: ZonElement) u16 {
|
||||||
const modelId = zon.as([]const u8, "cubyz:cube");
|
const modelId = zon.as([]const u8, "cubyz:cube");
|
||||||
if(rotatedModels.get(modelId)) |modelIndex| return modelIndex;
|
if(rotatedModels.get(modelId)) |modelIndex| return modelIndex;
|
||||||
@ -250,6 +259,10 @@ pub const RotationModes = struct {
|
|||||||
fenceModels.deinit();
|
fenceModels.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reset() void {
|
||||||
|
fenceModels.clearRetainingCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
fn fenceTransform(quad: *main.models.QuadInfo, data: FenceData) void {
|
fn fenceTransform(quad: *main.models.QuadInfo, data: FenceData) void {
|
||||||
for(&quad.corners, &quad.cornerUV) |*corner, *cornerUV| {
|
for(&quad.corners, &quad.cornerUV) |*corner, *cornerUV| {
|
||||||
if(!data.isConnectedNegX and corner[0] == 0) {
|
if(!data.isConnectedNegX and corner[0] == 0) {
|
||||||
@ -357,6 +370,10 @@ pub const RotationModes = struct {
|
|||||||
branchModels.deinit();
|
branchModels.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reset() void {
|
||||||
|
branchModels.clearRetainingCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
fn branchTransform(quad: *main.models.QuadInfo, data: BranchData) void {
|
fn branchTransform(quad: *main.models.QuadInfo, data: BranchData) void {
|
||||||
for(&quad.corners) |*corner| {
|
for(&quad.corners) |*corner| {
|
||||||
if((!data.isConnected(Neighbor.dirNegX) and corner[0] == 0) or
|
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;
|
return stairData & subBlockMask(x, y, z) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init() void {
|
fn init() void {}
|
||||||
|
fn deinit() void {}
|
||||||
|
fn reset() void {
|
||||||
modelIndex = 0;
|
modelIndex = 0;
|
||||||
}
|
}
|
||||||
fn deinit() void {}
|
|
||||||
|
|
||||||
const GreedyFaceInfo = struct {min: Vec2f, max: Vec2f};
|
const GreedyFaceInfo = struct {min: Vec2f, max: Vec2f};
|
||||||
fn mergeFaces(faceVisible: [2][2]bool, mem: []GreedyFaceInfo) []GreedyFaceInfo {
|
fn mergeFaces(faceVisible: [2][2]bool, mem: []GreedyFaceInfo) []GreedyFaceInfo {
|
||||||
@ -807,6 +825,10 @@ pub const RotationModes = struct {
|
|||||||
rotatedModels.deinit();
|
rotatedModels.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reset() void {
|
||||||
|
rotatedModels.clearRetainingCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn createBlockModel(zon: ZonElement) u16 {
|
pub fn createBlockModel(zon: ZonElement) u16 {
|
||||||
const baseModelId: []const u8 = zon.get([]const u8, "base", "cubyz:cube");
|
const baseModelId: []const u8 = zon.get([]const u8, "base", "cubyz:cube");
|
||||||
const sideModelId: []const u8 = zon.get([]const u8, "side", "cubyz:cube");
|
const sideModelId: []const u8 = zon.get([]const u8, "side", "cubyz:cube");
|
||||||
@ -980,6 +1002,10 @@ pub const RotationModes = struct {
|
|||||||
rotatedModels.deinit();
|
rotatedModels.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reset() void {
|
||||||
|
rotatedModels.clearRetainingCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn createBlockModel(zon: ZonElement) u16 {
|
pub fn createBlockModel(zon: ZonElement) u16 {
|
||||||
const modelId = zon.as([]const u8, "cubyz:cube");
|
const modelId = zon.as([]const u8, "cubyz:cube");
|
||||||
if(rotatedModels.get(modelId)) |modelIndex| return modelIndex;
|
if(rotatedModels.get(modelId)) |modelIndex| return modelIndex;
|
||||||
@ -1105,6 +1131,9 @@ pub const RotationModes = struct {
|
|||||||
|
|
||||||
fn init() void {}
|
fn init() void {}
|
||||||
fn deinit() void {}
|
fn deinit() void {}
|
||||||
|
fn reset() void {
|
||||||
|
modelCache = null;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn createBlockModel(zon: ZonElement) u16 {
|
pub fn createBlockModel(zon: ZonElement) u16 {
|
||||||
const modelId = zon.as([]const u8, "cubyz:cube");
|
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 {
|
pub fn deinit() void {
|
||||||
rotationModes.deinit();
|
rotationModes.deinit();
|
||||||
inline for(@typeInfo(RotationModes).@"struct".decls) |declaration| {
|
inline for(@typeInfo(RotationModes).@"struct".decls) |declaration| {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user