Fixed bug in 3D view developer tool.

This commit is contained in:
Daan Vanden Bosch 2021-11-29 22:47:28 +01:00
parent 9653a982c0
commit ed0db920d1
2 changed files with 19 additions and 11 deletions

View File

@ -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<AreaObjectUserData>().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(

View File

@ -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<AreaObjectUserData>()
val userData = mesh.userData.unsafeCast<AreaUserData>()
val areaObj = userData.areaObject
val textureIds = mutableSetOf<Int>()
@ -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: ")