Skip to content

Commit

Permalink
Added collision mask, restitution, and friction to physics entities
Browse files Browse the repository at this point in the history
  • Loading branch information
StewStrong committed Aug 20, 2023
1 parent 5791e10 commit c9e06ae
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,7 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity(
val physicsEntityDataAsBytes: ByteArray = compoundTag.getByteArray(PHYS_DATA_NBT_KEY)
val oldPhysicsEntityData = getMapper().readValue<PhysicsEntityData>(physicsEntityDataAsBytes)
val newShipId = (level.shipObjectWorld as ShipObjectServerWorld).allocateShipId(level.dimensionId)
val newPhysicsEntityData = PhysicsEntityData(
shipId = newShipId,
transform = oldPhysicsEntityData.transform,
inertiaData = oldPhysicsEntityData.inertiaData,
linearVelocity = oldPhysicsEntityData.linearVelocity,
angularVelocity = oldPhysicsEntityData.angularVelocity,
collisionShapeData = oldPhysicsEntityData.collisionShapeData,
isStatic = oldPhysicsEntityData.isStatic,
)
val newPhysicsEntityData = oldPhysicsEntityData.copyPhysicsEntityDataWithNewId(newShipId)
// Change the shipId to be something new
setPhysicsEntityData(newPhysicsEntityData)
super.load(compoundTag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class PhysicsEntityCreatorItem(
val entityPos = ctx.clickLocation.toJOML().add(offset)
val transform = Companion.create(entityPos, Vector3d())
val physicsEntityData = VSPhysicsEntity.createBasicSphereData(shipId, transform, sphereRadius)
physicsEntityData.dynamicFrictionCoefficient = 1.0
physicsEntityData.staticFrictionCoefficient = 1.0
physicsEntityData.restitutionCoefficient = 0.0
entity.setPhysicsEntityData(physicsEntityData)
entity.setPos(entityPos.x, entityPos.y, entityPos.z)
level.addFreshEntity(entity)
Expand Down
2 changes: 1 addition & 1 deletion forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ dependencies {
transitive = false
}

forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+61e725b93e") {
forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+f053c720c5") {
transitive = false
}

Expand Down
2 changes: 1 addition & 1 deletion vs-core

0 comments on commit c9e06ae

Please sign in to comment.