Skip to content

Commit

Permalink
Updated to latest VS2
Browse files Browse the repository at this point in the history
  • Loading branch information
StewStrong committed Aug 31, 2023
1 parent 652a4bd commit 25f6aa1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 39 deletions.
11 changes: 11 additions & 0 deletions common/src/main/kotlin/org/valkyrienskies/eureka/EurekaWeights.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties
import org.valkyrienskies.core.apigame.world.chunks.BlockType
import org.valkyrienskies.mod.common.BlockStateInfo
import org.valkyrienskies.mod.common.BlockStateInfoProvider
import org.valkyrienskies.physics_api.Lod1BlockStateId
import org.valkyrienskies.physics_api.Lod1LiquidBlockStateId
import org.valkyrienskies.physics_api.Lod1SolidBlockStateId
import org.valkyrienskies.physics_api.voxel.Lod1LiquidBlockState
import org.valkyrienskies.physics_api.voxel.Lod1SolidBlockState

object EurekaWeights : BlockStateInfoProvider {
override val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>>
get() = emptyList()
override val liquidBlockStates: List<Lod1LiquidBlockState>
get() = emptyList()
override val priority: Int
get() = 200
override val solidBlockStates: List<Lod1SolidBlockState>
get() = emptyList()

override fun getBlockStateMass(blockState: BlockState): Double? {
if (blockState.block == EurekaBlocks.BALLAST.get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ import org.joml.Vector3dc
import org.valkyrienskies.core.api.VSBeta
import org.valkyrienskies.core.api.ships.PhysShip
import org.valkyrienskies.core.api.ships.ServerShip
import org.valkyrienskies.core.api.ships.ShipForcesInducer
import org.valkyrienskies.core.api.ships.getAttachment
import org.valkyrienskies.core.api.ships.saveAttachment
import org.valkyrienskies.core.impl.api.ServerShipUser
import org.valkyrienskies.core.impl.api.ShipForcesInducer
import org.valkyrienskies.core.impl.api.Ticked
import org.valkyrienskies.core.impl.api.shipValue
import org.valkyrienskies.core.impl.game.ships.PhysShipImpl
import org.valkyrienskies.core.impl.pipelines.SegmentUtils
import org.valkyrienskies.eureka.EurekaConfig
import org.valkyrienskies.mod.api.SeatedControllingPlayer
import org.valkyrienskies.mod.common.util.toJOMLD
Expand Down Expand Up @@ -103,9 +102,8 @@ class EurekaShipControl : ShipForcesInducer, ServerShipUser, Ticked {
val ship = ship ?: return
val mass = physShip.inertia.shipMass
val moiTensor = physShip.inertia.momentOfInertiaTensor
val segment = physShip.segments.segments[0]?.segmentDisplacement!!
val omega: Vector3dc = SegmentUtils.getOmega(physShip.poseVel, segment, Vector3d())
val vel = SegmentUtils.getVelocity(physShip.poseVel, segment, Vector3d())
val omega: Vector3dc = physShip.poseVel.omega
val vel: Vector3dc = physShip.poseVel.vel
val balloonForceProvided = balloons * forcePerBalloon


Expand Down Expand Up @@ -160,7 +158,6 @@ class EurekaShipControl : ShipForcesInducer, ServerShipUser, Ticked {
physShip,
omega,
vel,
segment,
physShip,
controllingPlayer == null && !aligning,
controllingPlayer == null
Expand Down Expand Up @@ -250,31 +247,18 @@ class EurekaShipControl : ShipForcesInducer, ServerShipUser, Ticked {

rotationVector.mul(idealAlphaY * -1.5)

SegmentUtils.transformDirectionWithScale(
physShip.poseVel,
segment,
physShip.poseVel.rot.transform(
moiTensor.transform(
SegmentUtils.invTransformDirectionWithScale(
physShip.poseVel,
segment,
rotationVector,
rotationVector
)
),
rotationVector
physShip.poseVel.rot.transformInverse(rotationVector)
)
)

physShip.applyInvariantTorque(rotationVector)
// endregion

// region Player controlled forward and backward thrust
val forwardVector = control.seatInDirection.normal.toJOMLD()
SegmentUtils.transformDirectionWithoutScale(
physShip.poseVel,
segment,
forwardVector,
forwardVector
)
physShip.poseVel.rot.transform(forwardVector)
forwardVector.y *= 0.1 // Reduce vertical thrust
forwardVector.normalize()

Expand Down
19 changes: 4 additions & 15 deletions common/src/main/kotlin/org/valkyrienskies/eureka/ship/Stabilize.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ import org.joml.Vector3d
import org.joml.Vector3dc
import org.valkyrienskies.core.api.ships.PhysShip
import org.valkyrienskies.core.impl.game.ships.PhysShipImpl
import org.valkyrienskies.core.impl.pipelines.SegmentUtils
import org.valkyrienskies.eureka.EurekaConfig
import org.valkyrienskies.physics_api.SegmentDisplacement

fun stabilize(
ship: PhysShipImpl,
omega: Vector3dc,
vel: Vector3dc,
segment: SegmentDisplacement,
forces: PhysShip,
linear: Boolean,
yaw: Boolean
) {
val shipUp = Vector3d(0.0, 1.0, 0.0)
val worldUp = Vector3d(0.0, 1.0, 0.0)
SegmentUtils.transformDirectionWithoutScale(ship.poseVel, segment, shipUp, shipUp)
ship.poseVel.rot.transform(shipUp)

val angleBetween = shipUp.angle(worldUp)
val idealAngularAcceleration = Vector3d()
Expand All @@ -42,18 +39,10 @@ fun stabilize(
omega.z()
)

val stabilizationTorque = SegmentUtils.transformDirectionWithScale(
ship.poseVel,
segment,
val stabilizationTorque = ship.poseVel.rot.transform(
ship.inertia.momentOfInertiaTensor.transform(
SegmentUtils.invTransformDirectionWithScale(
ship.poseVel,
segment,
idealAngularAcceleration,
idealAngularAcceleration
)
),
idealAngularAcceleration
ship.poseVel.rot.transformInverse(idealAngularAcceleration)
)
)

stabilizationTorque.mul(EurekaConfig.SERVER.stabilizationTorqueConstant)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ enabled_platforms=fabric,forge
archives_base_name=eureka
maven_group=org.valkyrienskies
# Dependencies
vs2_version=2.1.0-beta.14+acba7d4175
vs2_version=2.1.0-beta.15+ff2f775e37
minecraft_version=1.18.2
architectury_version=4.10.86
fabric_loader_version=0.14.10
Expand Down

0 comments on commit 25f6aa1

Please sign in to comment.