rename bounce to bounciness

This commit is contained in:
codemob-dev 2025-07-26 10:42:20 -04:00
parent 134e8ca92c
commit 1aef45e9c9
5 changed files with 18 additions and 18 deletions

View File

@ -1,7 +1,7 @@
.{ .{
.tags = .{.choppable, .cuttable}, .tags = .{.choppable, .cuttable},
.blockHealth = 3, .blockHealth = 3,
.bounce = 0.75, .bounciness = 0.75,
.drops = .{ .drops = .{
.{.items = .{.auto}}, .{.items = .{.auto}},
}, },

View File

@ -1,7 +1,7 @@
.{ .{
.tags = .{.choppable, .cuttable}, .tags = .{.choppable, .cuttable},
.blockHealth = 3, .blockHealth = 3,
.bounce = 0.5, .bounciness = 0.5,
.drops = .{ .drops = .{
.{.items = .{.auto}}, .{.items = .{.auto}},
}, },

View File

@ -1,7 +1,7 @@
.{ .{
.tags = .{.choppable, .cuttable}, .tags = .{.choppable, .cuttable},
.blockHealth = 3, .blockHealth = 3,
.bounce = 1.0, .bounciness = 1.0,
.drops = .{ .drops = .{
.{.items = .{.auto}}, .{.items = .{.auto}},
}, },

View File

@ -79,7 +79,7 @@ var _lodReplacement: [maxBlockCount]u16 = undefined;
var _opaqueVariant: [maxBlockCount]u16 = undefined; var _opaqueVariant: [maxBlockCount]u16 = undefined;
var _friction: [maxBlockCount]f32 = undefined; var _friction: [maxBlockCount]f32 = undefined;
var _bounce: [maxBlockCount]f32 = undefined; var _bounciness: [maxBlockCount]f32 = undefined;
var _density: [maxBlockCount]f32 = undefined; var _density: [maxBlockCount]f32 = undefined;
var _terminalVelocity: [maxBlockCount]f32 = undefined; var _terminalVelocity: [maxBlockCount]f32 = undefined;
var _mobility: [maxBlockCount]f32 = undefined; var _mobility: [maxBlockCount]f32 = undefined;
@ -133,7 +133,7 @@ pub fn register(_: []const u8, id: []const u8, zon: ZonElement) u16 {
_viewThrough[size] = zon.get(bool, "viewThrough", false) or _transparent[size] or _alwaysViewThrough[size]; _viewThrough[size] = zon.get(bool, "viewThrough", false) or _transparent[size] or _alwaysViewThrough[size];
_hasBackFace[size] = zon.get(bool, "hasBackFace", false); _hasBackFace[size] = zon.get(bool, "hasBackFace", false);
_friction[size] = zon.get(f32, "friction", 20); _friction[size] = zon.get(f32, "friction", 20);
_bounce[size] = zon.get(f32, "bounce", 0.0); _bounciness[size] = zon.get(f32, "bounciness", 0.0);
_density[size] = zon.get(f32, "density", 0.001); _density[size] = zon.get(f32, "density", 0.001);
_terminalVelocity[size] = zon.get(f32, "terminalVelocity", 90); _terminalVelocity[size] = zon.get(f32, "terminalVelocity", 90);
_mobility[size] = zon.get(f32, "mobility", 1.0); _mobility[size] = zon.get(f32, "mobility", 1.0);
@ -401,8 +401,8 @@ pub const Block = packed struct { // MARK: Block
return _friction[self.typ]; return _friction[self.typ];
} }
pub inline fn bounce(self: Block) f32 { pub inline fn bounciness(self: Block) f32 {
return _bounce[self.typ]; return _bounciness[self.typ];
} }
pub inline fn density(self: Block) f32 { pub inline fn density(self: Block) f32 {

View File

@ -281,7 +281,7 @@ pub const collision = struct {
const SurfaceProperties = struct { const SurfaceProperties = struct {
friction: f32, friction: f32,
bounce: f32, bounciness: f32,
}; };
pub fn calculateSurfaceProperties(comptime side: main.utils.Side, pos: Vec3d, hitBox: Box, defaultFriction: f32) SurfaceProperties { pub fn calculateSurfaceProperties(comptime side: main.utils.Side, pos: Vec3d, hitBox: Box, defaultFriction: f32) SurfaceProperties {
@ -297,7 +297,7 @@ pub const collision = struct {
const z: i32 = @intFromFloat(@floor(boundingBox.min[2] - 0.01)); const z: i32 = @intFromFloat(@floor(boundingBox.min[2] - 0.01));
var friction: f64 = 0; var friction: f64 = 0;
var bounce: f64 = 0; var bounciness: f64 = 0;
var totalArea: f64 = 0; var totalArea: f64 = 0;
var x = minX; var x = minX;
@ -326,7 +326,7 @@ pub const collision = struct {
if(block.collide()) { if(block.collide()) {
totalArea += area; totalArea += area;
friction += area*@as(f64, @floatCast(block.friction())); friction += area*@as(f64, @floatCast(block.friction()));
bounce += area*@as(f64, @floatCast(block.bounce())); bounciness += area*@as(f64, @floatCast(block.bounciness()));
} }
} }
} }
@ -334,15 +334,15 @@ pub const collision = struct {
if(totalArea == 0) { if(totalArea == 0) {
friction = defaultFriction; friction = defaultFriction;
bounce = 0.0; bounciness = 0.0;
} else { } else {
friction = friction/totalArea; friction = friction/totalArea;
bounce = bounce/totalArea; bounciness = bounciness/totalArea;
} }
return .{ return .{
.friction = @floatCast(friction), .friction = @floatCast(friction),
.bounce = @floatCast(bounce), .bounciness = @floatCast(bounciness),
}; };
} }
@ -1277,14 +1277,14 @@ pub fn update(deltaTime: f64) void { // MARK: update()
} else { } else {
Player.super.pos[2] = box.min[2] - hitBox.max[2]; Player.super.pos[2] = box.min[2] - hitBox.max[2];
} }
var bounce = if(Player.isFlying.load(.monotonic)) 0 else collision.calculateSurfaceProperties(.client, Player.super.pos, Player.outerBoundingBox, 0.0).bounce; var bounciness = if(Player.isFlying.load(.monotonic)) 0 else collision.calculateSurfaceProperties(.client, Player.super.pos, Player.outerBoundingBox, 0.0).bounciness;
if(KeyBoard.key("crouch").pressed) { if(KeyBoard.key("crouch").pressed) {
bounce *= 0.5; bounciness *= 0.5;
} }
var velocityChange: f64 = undefined; var velocityChange: f64 = undefined;
if(bounce != 0.0 and Player.super.vel[2] < -3.0) { if(bounciness != 0.0 and Player.super.vel[2] < -3.0) {
velocityChange = Player.super.vel[2]*@as(f64, @floatCast(1 - bounce)); velocityChange = Player.super.vel[2]*@as(f64, @floatCast(1 - bounciness));
Player.super.vel[2] = -Player.super.vel[2]*bounce; Player.super.vel[2] = -Player.super.vel[2]*bounciness;
Player.jumpCoyote = Player.jumpCoyoteTimeConstant + deltaTime; Player.jumpCoyote = Player.jumpCoyoteTimeConstant + deltaTime;
} else { } else {
velocityChange = Player.super.vel[2]; velocityChange = Player.super.vel[2];