diff --git a/web/src/main/kotlin/world/phantasmal/web/questEditor/loading/AreaAssetLoader.kt b/web/src/main/kotlin/world/phantasmal/web/questEditor/loading/AreaAssetLoader.kt index f66f268a..acb4c251 100644 --- a/web/src/main/kotlin/world/phantasmal/web/questEditor/loading/AreaAssetLoader.kt +++ b/web/src/main/kotlin/world/phantasmal/web/questEditor/loading/AreaAssetLoader.kt @@ -1,7 +1,8 @@ package world.phantasmal.web.questEditor.loading import org.khronos.webgl.ArrayBuffer -import world.phantasmal.core.* +import world.phantasmal.core.asJsArray +import world.phantasmal.core.isBitSet import world.phantasmal.core.unsafe.UnsafeSet import world.phantasmal.core.unsafe.unsafeSetOf import world.phantasmal.psolib.Endianness @@ -19,10 +20,11 @@ import world.phantasmal.web.externals.three.* import world.phantasmal.web.questEditor.models.AreaVariantModel import world.phantasmal.web.questEditor.models.SectionModel import world.phantasmal.webui.DisposableContainer +import kotlin.collections.set import kotlin.math.PI import kotlin.math.cos -class AreaUserData(val section: SectionModel?) +class AreaUserData(val section: SectionModel?, val areaObject: AreaObject) /** * Loads and caches area assets. @@ -184,8 +186,8 @@ class AreaAssetLoader(private val assetLoader: AssetLoader) : DisposableContaine } } - if (renderSection.id >= 0) { - val sectionModel = sections.getOrPut(renderSection.id) { + val sectionModel = if (renderSection.id >= 0) { + sections.getOrPut(renderSection.id) { SectionModel( renderSection.id, vec3ToThree(renderSection.position), @@ -193,9 +195,14 @@ class AreaAssetLoader(private val assetLoader: AssetLoader) : DisposableContaine areaVariant, ) } - - mesh.userData = AreaUserData(sectionModel) + } else { + null } + + mesh.userData = AreaUserData( + sectionModel, + mesh.userData.unsafeCast().areaObject, + ) } return Pair(group, sections.values.toList()) @@ -774,7 +781,9 @@ class AreaAssetLoader(private val assetLoader: AssetLoader) : DisposableContaine ), // Central Control Area Pair(Episode.II, 5) to Fix( - renderOnTopTextures = unsafeSetOf(*((0..59).toSet() + setOf(69, 77)).toTypedArray()), + renderOnTopTextures = unsafeSetOf( + *((0..59).toSet() + setOf(69, 77)).toTypedArray(), + ), ), // Jungle Area East Pair(Episode.II, 6) to Fix( diff --git a/web/src/main/kotlin/world/phantasmal/web/questEditor/rendering/input/state/StateContext.kt b/web/src/main/kotlin/world/phantasmal/web/questEditor/rendering/input/state/StateContext.kt index 9b6bf2aa..f8a74265 100644 --- a/web/src/main/kotlin/world/phantasmal/web/questEditor/rendering/input/state/StateContext.kt +++ b/web/src/main/kotlin/world/phantasmal/web/questEditor/rendering/input/state/StateContext.kt @@ -2,13 +2,12 @@ package world.phantasmal.web.questEditor.rendering.input.state import mu.KotlinLogging import world.phantasmal.core.asJsArray -import world.phantasmal.psolib.fileFormats.ninja.XjObject import world.phantasmal.observable.cell.Cell +import world.phantasmal.psolib.fileFormats.ninja.XjObject import world.phantasmal.web.core.dot import world.phantasmal.web.core.minusAssign import world.phantasmal.web.core.plusAssign import world.phantasmal.web.core.rendering.OrbitalCameraInputManager -import world.phantasmal.web.core.rendering.conversion.AreaObjectUserData import world.phantasmal.web.core.rendering.conversion.fingerPrint import world.phantasmal.web.externals.three.* import world.phantasmal.web.questEditor.actions.CreateEntityAction @@ -264,7 +263,7 @@ class StateContext( if (mesh != null) { logger.info { - val userData = mesh.userData.unsafeCast() + val userData = mesh.userData.unsafeCast() val areaObj = userData.areaObject val textureIds = mutableSetOf() @@ -278,7 +277,7 @@ class StateContext( buildString { append("Section ") - append(userData.sectionId) + append(userData.section?.id ?: 0) append(" (finger print: ") append(areaObj.fingerPrint()) append(", texture IDs: ")