Skip to content

Commit

Permalink
Renamed some methods and cleaned up some code in BreastPhysics.java
Browse files Browse the repository at this point in the history
  • Loading branch information
WildfireRomeo committed Dec 1, 2023
1 parent 6daa84d commit 28d04b8
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 80 deletions.
119 changes: 54 additions & 65 deletions src/main/java/com/wildfire/physics/BreastPhysics.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@

public class BreastPhysics {

private float bounceVel = 0, targetBounceY = 0, velocity = 0, wfg_femaleBreast, wfg_preBounce;
//X-Axis
private float bounceVelX = 0, targetBounceX = 0, velocityX = 0, positionX, prePositionX;
//Y-Axis
private float bounceVel = 0, targetBounceY = 0, velocity = 0, positionY, prePositionY;
//Rotation
private float bounceRotVel = 0, targetRotVel = 0, rotVelocity = 0, wfg_bounceRotation, wfg_preBounceRotation;
private float bounceVelX = 0, targetBounceX = 0, velocityX = 0, wfg_femaleBreastX, wfg_preBounceX;

private boolean justSneaking = false, alreadySleeping = false;

Expand All @@ -62,8 +65,8 @@ public void update(LivingEntity entity, IGenderArmor armor) {
return;
}

this.wfg_preBounce = this.wfg_femaleBreast;
this.wfg_preBounceX = this.wfg_femaleBreastX;
this.prePositionY = this.positionY;
this.prePositionX = this.positionX;
this.wfg_preBounceRotation = this.wfg_bounceRotation;
this.preBreastSize = this.breastSize;

Expand All @@ -72,43 +75,43 @@ public void update(LivingEntity entity, IGenderArmor armor) {
return;
}

float h = 0; //tickDelta
{
float h = 0; //tickDelta
float i = entity.getLeaningPitch(0);
float j;
float k;

float i = entity.getLeaningPitch(0);
float j;
float k;
float bodyXRotation = 0;
float bodyYRotation = 0;

float bodyXRotation = 0;
float bodyYRotation = 0;

if (entity.isFallFlying()) {
j = (float) entity.getRoll() + h;
k = MathHelper.clamp(j * j / 100.0F, 0.0F, 1.0F);
if (!entity.isUsingRiptide()) {
bodyXRotation = k * (-90.0F - entity.getPitch());
}
if (entity.isFallFlying()) {
j = (float) entity.getRoll() + h;
k = MathHelper.clamp(j * j / 100.0F, 0.0F, 1.0F);
if (!entity.isUsingRiptide()) {
bodyXRotation = k * (-90.0F - entity.getPitch());
}

if(entity instanceof AbstractClientPlayerEntity player) {
Vec3d vec3d = entity.getRotationVec(h);
Vec3d vec3d2 = player.lerpVelocity(h);
double d = vec3d2.horizontalLengthSquared();
double e = vec3d.horizontalLengthSquared();
if (d > 0.0 && e > 0.0) {
double l = (vec3d2.x * vec3d.x + vec3d2.z * vec3d.z) / Math.sqrt(d * e);
double m = vec3d2.x * vec3d.z - vec3d2.z * vec3d.x;
bodyYRotation = (float) (Math.signum(m) * Math.acos(l));
if (entity instanceof AbstractClientPlayerEntity player) {
Vec3d vec3d = entity.getRotationVec(h);
Vec3d vec3d2 = player.lerpVelocity(h);
double d = vec3d2.horizontalLengthSquared();
double e = vec3d.horizontalLengthSquared();
if (d > 0.0 && e > 0.0) {
double l = (vec3d2.x * vec3d.x + vec3d2.z * vec3d.z) / Math.sqrt(d * e);
double m = vec3d2.x * vec3d.z - vec3d2.z * vec3d.x;
bodyYRotation = (float) (Math.signum(m) * Math.acos(l));
}
}
} else if (i > 0.0F) {
j = entity.isTouchingWater() ? -90.0F - entity.getPitch() : -90.0F;
k = MathHelper.lerp(i, 0.0F, j);
bodyXRotation = k;
} else if (entity.isSleeping()) {
bodyXRotation = 90f;
} else if (entity.getPose() == EntityPose.CROUCHING) {
bodyXRotation = -15f;
}
} else if (i > 0.0F) {
j = entity.isTouchingWater() ? -90.0F - entity.getPitch() : -90.0F;
k = MathHelper.lerp(i, 0.0F, j);
bodyXRotation = k;
} else if(entity.isSleeping()) {
bodyXRotation = 90f;
} else if(entity.getPose() == EntityPose.CROUCHING) {
bodyXRotation = -15f;
}

} //unused currently, might be later

float breastWeight = entityConfig.getBustSize() * 1.25f;
float targetBreastSize = entityConfig.getBustSize();
Expand All @@ -118,21 +121,14 @@ public void update(LivingEntity entity, IGenderArmor armor) {
} else {
float tightness = MathHelper.clamp(armor.tightness(), 0, 1);
if(entityConfig.getArmorPhysicsOverride()) tightness = 0; //override resistance

//Scale breast size by how tight the armor is, clamping at a max adjustment of shrinking by 0.15
targetBreastSize *= 1 - 0.15F * tightness;
}

if(breastSize < targetBreastSize) {
breastSize += Math.abs(breastSize - targetBreastSize) / 2f;
} else {
breastSize -= Math.abs(breastSize - targetBreastSize) / 2f;
}

breastSize += (breastSize < targetBreastSize) ? Math.abs(breastSize - targetBreastSize) / 2f : -Math.abs(breastSize - targetBreastSize) / 2f;

Vec3d motion = entity.getPos().subtract(this.prePos);
this.prePos = entity.getPos();
//System.out.println(motion);

float bounceIntensity = (targetBreastSize * 3f) * Math.round((entityConfig.getBounceMultiplier() * 3) * 100) / 100f;
float resistance = MathHelper.clamp(armor.physicsResistance(), 0, 1);
Expand All @@ -154,17 +150,13 @@ public void update(LivingEntity entity, IGenderArmor armor) {
this.targetBounceY = (float) motion.y * bounceIntensity;
this.targetBounceY += breastWeight;
float horizVel = (float) Math.sqrt(Math.pow(motion.x, 2) + Math.pow(motion.z, 2)) * (bounceIntensity);
//float horizLocal = -horizVel * ((plr.getRotationYawHead()-plr.renderYawOffset)<0?-1:1);
this.targetRotVel = -((entity.bodyYaw - entity.prevBodyYaw) / 15f) * bounceIntensity;

//System.out.println("Body Rotation: " + (bodyXRotation) / 90);

float f2 = (float) entity.getVelocity().lengthSquared() / 0.2F;
f2 = f2 * f2 * f2;
if(f2 < 1.0F) f2 = 1.0F;

this.targetBounceY += MathHelper.cos(entity.limbAnimator.getPos() * 0.6662F + (float)Math.PI) * 0.5F * entity.limbAnimator.getSpeed() * 0.5F / f2;
//System.out.println(plr.rotationYaw);

this.targetRotVel += (float) motion.y * bounceIntensity * randomB;

Expand All @@ -178,7 +170,6 @@ public void update(LivingEntity entity, IGenderArmor armor) {
this.targetBounceY += bounceIntensity;
}


//button option for extra entities
if(entity.getVehicle() != null) {
if(entity.getVehicle() instanceof BoatEntity boat) {
Expand Down Expand Up @@ -231,8 +222,7 @@ public void update(LivingEntity entity, IGenderArmor armor) {
/*if(plr.getPose() == EntityPose.SWIMMING) {
//System.out.println(1 - plr.getRotationVec(tickDelta).getY());
rotationMultiplier = 1 - (float) plr.getRotationVec(tickDelta).getY();
}
*/
}*/


float percent = entityConfig.getFloppiness();
Expand All @@ -256,7 +246,6 @@ public void update(LivingEntity entity, IGenderArmor armor) {
if(targetRotVel > 25f) targetRotVel = 25f;

this.velocity = MathHelper.lerp(bounceAmount, this.velocity, (this.targetBounceY - this.bounceVel) * delta);
//this.preY = MathHelper.lerp(0.5f, this.preY, (this.targetBounce - this.bounceVel) * 1.25f);
this.bounceVel += this.velocity * percent * 1.1625f;

//X
Expand All @@ -267,12 +256,12 @@ public void update(LivingEntity entity, IGenderArmor armor) {
this.bounceRotVel += this.rotVelocity * percent;

this.wfg_bounceRotation = this.bounceRotVel;
this.wfg_femaleBreastX = this.bounceVelX;
this.wfg_femaleBreast = this.bounceVel;
this.positionX = this.bounceVelX;
this.positionY = this.bounceVel;

if(this.wfg_femaleBreast < -0.5f) this.wfg_femaleBreast = -0.5f;
if(this.wfg_femaleBreast > 1.5f) {
this.wfg_femaleBreast = 1.5f;
if(this.positionY < -0.5f) this.positionY = -0.5f;
if(this.positionY > 1.5f) {
this.positionY = 1.5f;
this.velocity = 0;
}

Expand All @@ -282,18 +271,18 @@ public float getBreastSize(float partialTicks) {
return MathHelper.lerp(partialTicks, preBreastSize, breastSize);
}

public float getPreBounceY() {
return this.wfg_preBounce;
public float getPrePositionY() {
return this.prePositionY;
}
public float getBounceY() {
return this.wfg_femaleBreast;
public float getPositionY() {
return this.positionY;
}

public float getPreBounceX() {
return this.wfg_preBounceX;
public float getPrePositionX() {
return this.prePositionX;
}
public float getBounceX() {
return this.wfg_femaleBreastX;
public float getPositionX() {
return this.positionX;
}

public float getBounceRotation() {
Expand Down
30 changes: 15 additions & 15 deletions src/main/java/com/wildfire/render/GenderLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public class GenderLayer<T extends LivingEntity, M extends BipedEntityModel<T>>
protected ItemStack armorStack;
protected IGenderArmor genderArmor;
protected boolean isChestplateOccupied, bounceEnabled, breathingAnimation;
protected float breastOffsetX, breastOffsetY, breastOffsetZ, lTotal, lTotalX, rTotal, rTotalX,
leftBounceRotation, rightBounceRotation, breastSize, zOffset, outwardAngle;
protected float breastOffsetX, breastOffsetY, breastOffsetZ, lPhysPositionY, lPhysPositionX, rPhysPositionY, rTotalX,
lPhysBounceRotation, rPhysBounceRotation, breastSize, zOffset, outwardAngle;

public GenderLayer(FeatureRendererContext<T, M> render) {
super(render);
Expand Down Expand Up @@ -182,18 +182,18 @@ protected boolean setupRender(T entity, EntityConfig entityConfig, float partial
preBreastSize = bSize;
}

lTotal = MathHelper.lerp(partialTicks, leftBreastPhysics.getPreBounceY(), leftBreastPhysics.getBounceY());
lTotalX = MathHelper.lerp(partialTicks, leftBreastPhysics.getPreBounceX(), leftBreastPhysics.getBounceX());
leftBounceRotation = MathHelper.lerp(partialTicks, leftBreastPhysics.getPreBounceRotation(), leftBreastPhysics.getBounceRotation());
lPhysPositionY = MathHelper.lerp(partialTicks, leftBreastPhysics.getPrePositionY(), leftBreastPhysics.getPositionY());
lPhysPositionX = MathHelper.lerp(partialTicks, leftBreastPhysics.getPrePositionX(), leftBreastPhysics.getPositionX());
lPhysBounceRotation = MathHelper.lerp(partialTicks, leftBreastPhysics.getPreBounceRotation(), leftBreastPhysics.getBounceRotation());
if(breasts.isUniboob()) {
rTotal = lTotal;
rTotalX = lTotalX;
rightBounceRotation = leftBounceRotation;
rPhysPositionY = lPhysPositionY;
rTotalX = lPhysPositionX;
rPhysBounceRotation = lPhysBounceRotation;
} else {
BreastPhysics rightBreastPhysics = entityConfig.getRightBreastPhysics();
rTotal = MathHelper.lerp(partialTicks, rightBreastPhysics.getPreBounceY(), rightBreastPhysics.getBounceY());
rTotalX = MathHelper.lerp(partialTicks, rightBreastPhysics.getPreBounceX(), rightBreastPhysics.getBounceX());
rightBounceRotation = MathHelper.lerp(partialTicks, rightBreastPhysics.getPreBounceRotation(), rightBreastPhysics.getBounceRotation());
rPhysPositionY = MathHelper.lerp(partialTicks, rightBreastPhysics.getPrePositionY(), rightBreastPhysics.getPositionY());
rTotalX = MathHelper.lerp(partialTicks, rightBreastPhysics.getPrePositionX(), rightBreastPhysics.getPositionX());
rPhysBounceRotation = MathHelper.lerp(partialTicks, rightBreastPhysics.getPreBounceRotation(), rightBreastPhysics.getBounceRotation());
}
breastSize = bSize * 1.5f;
if(breastSize > 0.7f) breastSize = 0.7f;
Expand Down Expand Up @@ -227,8 +227,8 @@ protected void setupTransformations(T entity, ModelPart body, MatrixStack matrix
}

if(bounceEnabled) {
matrixStack.translate((left ? lTotalX : rTotalX) / 32f, 0, 0);
matrixStack.translate(0, (left ? lTotal : rTotal) / 32f, 0);
matrixStack.translate((left ? lPhysPositionX : rTotalX) / 32f, 0, 0);
matrixStack.translate(0, (left ? lPhysPositionY : rPhysPositionY) / 32f, 0);
}

matrixStack.translate((left ? breastOffsetX : -breastOffsetX) * 0.0625f, 0.05625f + (breastOffsetY * 0.0625f), zOffset - 0.0625f * 2f + (breastOffsetZ * 0.0625f)); //shift down to correct position
Expand All @@ -237,7 +237,7 @@ protected void setupTransformations(T entity, ModelPart body, MatrixStack matrix
matrixStack.translate(-0.0625f * 2 * (left ? 1 : -1), 0, 0);
}
if(bounceEnabled) {
matrixStack.multiply(new Quaternionf().rotationXYZ(0, (float)((left ? leftBounceRotation : rightBounceRotation) * (Math.PI / 180f)), 0));
matrixStack.multiply(new Quaternionf().rotationXYZ(0, (float)((left ? lPhysBounceRotation : rPhysBounceRotation) * (Math.PI / 180f)), 0));
}
if(!breasts.isUniboob()) {
matrixStack.translate(0.0625f * 2 * (left ? 1 : -1), 0, 0);
Expand All @@ -246,7 +246,7 @@ protected void setupTransformations(T entity, ModelPart body, MatrixStack matrix
float rotationMultiplier = 0;
if(bounceEnabled) {
matrixStack.translate(0, -0.035f * breastSize, 0); //shift down to correct position
rotationMultiplier = -(left ? lTotal : rTotal) / 12f;
rotationMultiplier = -(left ? lPhysPositionY : rPhysPositionY) / 12f;
}
float totalRotation = breastSize + rotationMultiplier;
if(!bounceEnabled) {
Expand Down

0 comments on commit 28d04b8

Please sign in to comment.