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

commonMain.de.fabmax.kool.physics.Physics.kt Maven / Gradle / Ivy

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

object Physics {

    private val system = PhysicsSystem()

    val isLoaded: Boolean get() = system.isLoaded

    val defaultMaterial: Material get() = system.defaultMaterial

    suspend fun loadAndAwaitPhysics() = system.loadAndAwaitPhysics()
    fun checkIsLoaded() = system.checkIsLoaded()

    val NOTIFY_TOUCH_FOUND: Int get() = system.NOTIFY_TOUCH_FOUND
    val NOTIFY_TOUCH_LOST: Int get() = system.NOTIFY_TOUCH_LOST
    val NOTIFY_CONTACT_POINTS: Int get() = system.NOTIFY_CONTACT_POINTS
}

internal expect fun PhysicsSystem(): PhysicsSystem

internal interface PhysicsSystem {
    val isLoaded: Boolean

    val defaultMaterial: Material

    suspend fun loadAndAwaitPhysics()

    fun checkIsLoaded() {
        if (!isLoaded) {
            throw IllegalStateException("Physics subsystem is not loaded. Call loadAndAwaitPhysics() before using any physics functions.")
        }
    }

    val NOTIFY_TOUCH_FOUND: Int
    val NOTIFY_TOUCH_LOST: Int
    val NOTIFY_CONTACT_POINTS: Int
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy