Improved physics
This commit is contained in:
+28
-18
@@ -223,24 +223,34 @@ public class CloakFeatureRenderer extends FeatureRenderer<PlayerEntityRenderStat
|
|||||||
float xPos = -capeWidth / 2.0f + capeWidth * t;
|
float xPos = -capeWidth / 2.0f + capeWidth * t;
|
||||||
|
|
||||||
float centered = t - 0.5f;
|
float centered = t - 0.5f;
|
||||||
float curveFactor = centered * 2.0f;
|
float curve = (centered * centered) * 0.3f;
|
||||||
float falloff = Math.abs(curveFactor);
|
float zCurve = (curve * horizontalCurve) / PARTS;
|
||||||
float zCurve = (curveFactor * falloff * horizontalCurve * 0.3f) / PARTS;
|
|
||||||
|
|
||||||
for (int i = 0; i <= PARTS; i++) {
|
for (int i = 0; i <= PARTS; i++) {
|
||||||
|
|
||||||
float y = spineY[i];
|
float y = spineY[i];
|
||||||
float z = spineZ[i];
|
float z = spineZ[i];
|
||||||
|
|
||||||
int idx = Math.min(i, PARTS - 1);
|
int idx = Math.min(i, PARTS - 1);
|
||||||
|
// angle: 0 is horizontal (y-flat), PI/2 is vertical (z-flat)
|
||||||
float angle = (2.0f - segmentValues[idx]) * ((float) Math.PI / 2f);
|
float angle = (2.0f - segmentValues[idx]) * ((float) Math.PI / 2f);
|
||||||
|
|
||||||
float thickY = (float) Math.sin(angle) * capeDepth;
|
float cosA = (float) Math.cos(angle);
|
||||||
float thickZ = (float) Math.cos(angle) * capeDepth;
|
float sinA = (float) Math.sin(angle);
|
||||||
|
|
||||||
inner[x][i] = new Vec3d(xPos, y, z + (zCurve * i));
|
// Calculate how much the horizontal curve shifts the vertex
|
||||||
outer[x][i] = new Vec3d(xPos, y - thickY, z - thickZ + (zCurve * i));
|
float currentCurve = zCurve * i;
|
||||||
|
|
||||||
|
// Rotate the curve offset so it aligns with the cape's tilt
|
||||||
|
float curveY = sinA * currentCurve;
|
||||||
|
float curveZ = cosA * currentCurve;
|
||||||
|
|
||||||
|
float thickY = sinA * capeDepth;
|
||||||
|
float thickZ = cosA * capeDepth;
|
||||||
|
|
||||||
|
inner[x][i] = new Vec3d(xPos, y - curveY, z - curveZ);
|
||||||
|
outer[x][i] = new Vec3d(xPos, (y - curveY) - thickY, (z - curveZ) - thickZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================
|
// =============================
|
||||||
@@ -388,18 +398,18 @@ public class CloakFeatureRenderer extends FeatureRenderer<PlayerEntityRenderStat
|
|||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrices, OrderedRenderCommandQueue queue, int light, PlayerEntityRenderState state,
|
public void render(MatrixStack matrices, OrderedRenderCommandQueue queue, int light, PlayerEntityRenderState state,
|
||||||
float limbAngle, float limbDistance) {
|
float limbAngle, float limbDistance) {
|
||||||
// if (state.invisible || !state.capeVisible
|
if (state.invisible || !state.capeVisible
|
||||||
// || state.skinTextures.cape() != null) {
|
|| state.skinTextures.cape() != null) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// SaturnPlayer player = state.getData(SaturnRenderState.saturnDataKey);
|
SaturnPlayer player = state.getData(SaturnRenderState.saturnDataKey);
|
||||||
|
|
||||||
// if (player == null) {
|
if (player == null) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
IdentifierRef customCape = Cloaks.getCurrentCloakTexture("amg_petronas");
|
IdentifierRef customCape = Cloaks.getCurrentCloakTexture(player.cloak);
|
||||||
if (customCape == null
|
if (customCape == null
|
||||||
|| this.hasCustomModelForLayer(state.equippedChestStack, LayerType.WINGS)) {
|
|| this.hasCustomModelForLayer(state.equippedChestStack, LayerType.WINGS)) {
|
||||||
return;
|
return;
|
||||||
@@ -427,7 +437,7 @@ public class CloakFeatureRenderer extends FeatureRenderer<PlayerEntityRenderStat
|
|||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (now - lastUpdate >= 20) {
|
if (now - lastUpdate >= 20) {
|
||||||
float velX = Math.min(0.6f, state.field_53537 / 108.0f);
|
float velX = Math.min(0.8f, state.field_53537 / 108.0f);
|
||||||
float rawVelY = state.field_53536;
|
float rawVelY = state.field_53536;
|
||||||
float velY = (rawVelY > 3.4f ? rawVelY : rawVelY < -3.4f ? rawVelY : 0.0f) / 16;
|
float velY = (rawVelY > 3.4f ? rawVelY : rawVelY < -3.4f ? rawVelY : 0.0f) / 16;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user