mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-08 03:29:48 -04:00
Allow summing tool parameters instead of averaging them.
Currently everything uses average, but it does make some things less intuitive.
This commit is contained in:
parent
8f9ebe55fa
commit
beed67403e
@ -26,6 +26,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||||
},
|
},
|
||||||
.factor = 0.25,
|
.factor = 0.25,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .density,
|
.source = .density,
|
||||||
@ -38,6 +39,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||||
},
|
},
|
||||||
.factor = 0.4,
|
.factor = 0.4,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .hardness,
|
.source = .hardness,
|
||||||
@ -50,6 +52,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||||
},
|
},
|
||||||
.factor = 120,
|
.factor = 120,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .hardness,
|
.source = .hardness,
|
||||||
@ -62,6 +65,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||||
},
|
},
|
||||||
.factor = 0.3,
|
.factor = 0.3,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .elasticity,
|
.source = .elasticity,
|
||||||
@ -74,6 +78,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 1.5,
|
0x0, 0x0, 0x0, 0x0, 1.5,
|
||||||
},
|
},
|
||||||
.factor = 120,
|
.factor = 120,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .elasticity,
|
.source = .elasticity,
|
||||||
@ -86,6 +91,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.5,
|
0x0, 0x0, 0x0, 0x0, 0.5,
|
||||||
},
|
},
|
||||||
.factor = -1.0,
|
.factor = -1.0,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||||
},
|
},
|
||||||
.factor = 0.25,
|
.factor = 0.25,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .density,
|
.source = .density,
|
||||||
@ -38,6 +39,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||||
},
|
},
|
||||||
.factor = 0.8,
|
.factor = 0.8,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .hardness,
|
.source = .hardness,
|
||||||
@ -50,6 +52,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.5,
|
0x0, 0x0, 0x0, 0x0, 0.5,
|
||||||
},
|
},
|
||||||
.factor = 120,
|
.factor = 120,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .hardness,
|
.source = .hardness,
|
||||||
@ -62,6 +65,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||||
},
|
},
|
||||||
.factor = 0.7,
|
.factor = 0.7,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .elasticity,
|
.source = .elasticity,
|
||||||
@ -74,6 +78,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 1.5,
|
0x0, 0x0, 0x0, 0x0, 1.5,
|
||||||
},
|
},
|
||||||
.factor = 120,
|
.factor = 120,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .elasticity,
|
.source = .elasticity,
|
||||||
@ -86,6 +91,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||||
},
|
},
|
||||||
.factor = -1.0,
|
.factor = -1.0,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||||
},
|
},
|
||||||
.factor = 0.25,
|
.factor = 0.25,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .density,
|
.source = .density,
|
||||||
@ -38,6 +39,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||||
},
|
},
|
||||||
.factor = 0.4,
|
.factor = 0.4,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .hardness,
|
.source = .hardness,
|
||||||
@ -50,6 +52,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||||
},
|
},
|
||||||
.factor = 120,
|
.factor = 120,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .hardness,
|
.source = .hardness,
|
||||||
@ -62,6 +65,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||||
},
|
},
|
||||||
.factor = 0.2,
|
.factor = 0.2,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .elasticity,
|
.source = .elasticity,
|
||||||
@ -74,6 +78,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||||
},
|
},
|
||||||
.factor = 120,
|
.factor = 120,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .elasticity,
|
.source = .elasticity,
|
||||||
@ -86,6 +91,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||||
},
|
},
|
||||||
.factor = -1.0,
|
.factor = -1.0,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||||
},
|
},
|
||||||
.factor = 0.25,
|
.factor = 0.25,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .density,
|
.source = .density,
|
||||||
@ -38,6 +39,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||||
},
|
},
|
||||||
.factor = 0.8,
|
.factor = 0.8,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .hardness,
|
.source = .hardness,
|
||||||
@ -50,6 +52,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||||
},
|
},
|
||||||
.factor = 120,
|
.factor = 120,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .hardness,
|
.source = .hardness,
|
||||||
@ -62,6 +65,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||||
},
|
},
|
||||||
.factor = 0.7,
|
.factor = 0.7,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .elasticity,
|
.source = .elasticity,
|
||||||
@ -74,6 +78,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 1.5,
|
0x0, 0x0, 0x0, 0x0, 1.5,
|
||||||
},
|
},
|
||||||
.factor = 120,
|
.factor = 120,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
.{
|
.{
|
||||||
.source = .elasticity,
|
.source = .elasticity,
|
||||||
@ -86,6 +91,7 @@
|
|||||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||||
},
|
},
|
||||||
.factor = -1.0,
|
.factor = -1.0,
|
||||||
|
.method = .average,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -398,7 +398,12 @@ const ToolPhysics = struct { // MARK: ToolPhysics
|
|||||||
weight += property.weigths[i];
|
weight += property.weigths[i];
|
||||||
}
|
}
|
||||||
if(weight == 0) continue;
|
if(weight == 0) continue;
|
||||||
|
switch(property.method) {
|
||||||
|
.sum => {},
|
||||||
|
.average => {
|
||||||
sum /= weight;
|
sum /= weight;
|
||||||
|
},
|
||||||
|
}
|
||||||
sum *= property.resultScale;
|
sum *= property.resultScale;
|
||||||
tool.getProperty(property.destination orelse continue).* += sum;
|
tool.getProperty(property.destination orelse continue).* += sum;
|
||||||
}
|
}
|
||||||
@ -443,6 +448,19 @@ const PropertyMatrix = struct { // MARK: PropertyMatrix
|
|||||||
destination: ?ToolProperty,
|
destination: ?ToolProperty,
|
||||||
weigths: [25]f32,
|
weigths: [25]f32,
|
||||||
resultScale: f32,
|
resultScale: f32,
|
||||||
|
method: Method,
|
||||||
|
|
||||||
|
const Method = enum {
|
||||||
|
average,
|
||||||
|
sum,
|
||||||
|
|
||||||
|
fn fromString(string: []const u8) ?Method {
|
||||||
|
return std.meta.stringToEnum(Method, string) orelse {
|
||||||
|
std.log.err("Couldn't find property matrix method {s}.", .{string});
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const ToolType = struct { // MARK: ToolType
|
pub const ToolType = struct { // MARK: ToolType
|
||||||
@ -947,6 +965,7 @@ pub fn registerTool(assetFolder: []const u8, id: []const u8, zon: ZonElement) vo
|
|||||||
val.source = MaterialProperty.fromString(paramZon.get([]const u8, "source", "not specified"));
|
val.source = MaterialProperty.fromString(paramZon.get([]const u8, "source", "not specified"));
|
||||||
val.destination = ToolProperty.fromString(paramZon.get([]const u8, "destination", "not specified"));
|
val.destination = ToolProperty.fromString(paramZon.get([]const u8, "destination", "not specified"));
|
||||||
val.resultScale = paramZon.get(f32, "factor", 1.0);
|
val.resultScale = paramZon.get(f32, "factor", 1.0);
|
||||||
|
val.method = PropertyMatrix.Method.fromString(paramZon.get([]const u8, "method", "not specified")) orelse .sum;
|
||||||
const matrixZon = paramZon.getChild("matrix");
|
const matrixZon = paramZon.getChild("matrix");
|
||||||
for(0..25) |i| {
|
for(0..25) |i| {
|
||||||
val.weigths[i] = matrixZon.getAtIndex(f32, i, 0.0);
|
val.weigths[i] = matrixZon.getAtIndex(f32, i, 0.0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user