All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.de.fabmax.kool.physics.articulations.Articulation.kt Maven / Gradle / Ivy

There is a newer version: 0.15.1
Show newest version
package de.fabmax.kool.physics.articulations

import de.fabmax.kool.math.Mat4f
import de.fabmax.kool.util.BaseReleasable

expect fun Articulation(isFixedBase: Boolean): Articulation

abstract class Articulation : BaseReleasable() {
    protected val _links = mutableListOf()
    val links: List get() = _links

    val onFixedUpdate = mutableListOf<(Float) -> Unit>()

    abstract var minPositionIterations: Int
    abstract var minVelocityIterations: Int

    abstract fun createLink(parent: ArticulationLink?, pose: Mat4f): ArticulationLink

    abstract fun wakeUp()

    abstract fun putToSleep()

    fun onPhysicsUpdate(timeStep: Float) {
        for (i in links.indices) {
            links[i].onPhysicsUpdate(timeStep)
        }
        for (i in onFixedUpdate.indices) {
            onFixedUpdate[i](timeStep)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy