mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 03:06:55 -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,
|
||||
},
|
||||
.factor = 0.25,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .density,
|
||||
@ -38,6 +39,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||
},
|
||||
.factor = 0.4,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .hardness,
|
||||
@ -50,6 +52,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||
},
|
||||
.factor = 120,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .hardness,
|
||||
@ -62,6 +65,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||
},
|
||||
.factor = 0.3,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .elasticity,
|
||||
@ -74,6 +78,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 1.5,
|
||||
},
|
||||
.factor = 120,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .elasticity,
|
||||
@ -86,6 +91,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.5,
|
||||
},
|
||||
.factor = -1.0,
|
||||
.method = .average,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||
},
|
||||
.factor = 0.25,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .density,
|
||||
@ -38,6 +39,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||
},
|
||||
.factor = 0.8,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .hardness,
|
||||
@ -50,6 +52,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.5,
|
||||
},
|
||||
.factor = 120,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .hardness,
|
||||
@ -62,6 +65,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||
},
|
||||
.factor = 0.7,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .elasticity,
|
||||
@ -74,6 +78,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 1.5,
|
||||
},
|
||||
.factor = 120,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .elasticity,
|
||||
@ -86,6 +91,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||
},
|
||||
.factor = -1.0,
|
||||
.method = .average,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||
},
|
||||
.factor = 0.25,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .density,
|
||||
@ -38,6 +39,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||
},
|
||||
.factor = 0.4,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .hardness,
|
||||
@ -50,6 +52,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||
},
|
||||
.factor = 120,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .hardness,
|
||||
@ -62,6 +65,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||
},
|
||||
.factor = 0.2,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .elasticity,
|
||||
@ -74,6 +78,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||
},
|
||||
.factor = 120,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .elasticity,
|
||||
@ -86,6 +91,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||
},
|
||||
.factor = -1.0,
|
||||
.method = .average,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||
},
|
||||
.factor = 0.25,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .density,
|
||||
@ -38,6 +39,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||
},
|
||||
.factor = 0.8,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .hardness,
|
||||
@ -50,6 +52,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 1.0,
|
||||
},
|
||||
.factor = 120,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .hardness,
|
||||
@ -62,6 +65,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||
},
|
||||
.factor = 0.7,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .elasticity,
|
||||
@ -74,6 +78,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 1.5,
|
||||
},
|
||||
.factor = 120,
|
||||
.method = .average,
|
||||
},
|
||||
.{
|
||||
.source = .elasticity,
|
||||
@ -86,6 +91,7 @@
|
||||
0x0, 0x0, 0x0, 0x0, 0.0,
|
||||
},
|
||||
.factor = -1.0,
|
||||
.method = .average,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -398,7 +398,12 @@ const ToolPhysics = struct { // MARK: ToolPhysics
|
||||
weight += property.weigths[i];
|
||||
}
|
||||
if(weight == 0) continue;
|
||||
sum /= weight;
|
||||
switch(property.method) {
|
||||
.sum => {},
|
||||
.average => {
|
||||
sum /= weight;
|
||||
},
|
||||
}
|
||||
sum *= property.resultScale;
|
||||
tool.getProperty(property.destination orelse continue).* += sum;
|
||||
}
|
||||
@ -443,6 +448,19 @@ const PropertyMatrix = struct { // MARK: PropertyMatrix
|
||||
destination: ?ToolProperty,
|
||||
weigths: [25]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
|
||||
@ -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.destination = ToolProperty.fromString(paramZon.get([]const u8, "destination", "not specified"));
|
||||
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");
|
||||
for(0..25) |i| {
|
||||
val.weigths[i] = matrixZon.getAtIndex(f32, i, 0.0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user