From 7c234d2b1bae622b83034d6ceec5db804bf14916 Mon Sep 17 00:00:00 2001 From: AnsonYeung Date: Tue, 21 Apr 2026 23:19:06 +0800 Subject: [PATCH 1/6] compute on the fly --- .../scala/mrtjp/projectred/integration/components.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/scala/mrtjp/projectred/integration/components.scala b/src/main/scala/mrtjp/projectred/integration/components.scala index 331024e06..a401a4bce 100644 --- a/src/main/scala/mrtjp/projectred/integration/components.scala +++ b/src/main/scala/mrtjp/projectred/integration/components.scala @@ -241,11 +241,9 @@ abstract class ComponentModel { abstract class SingleComponentModel(m: CCModel, pos: Vector3 = Vector3.zero) extends ComponentModel { - val models = { - val xs = new Array[CCModel](48) + def models(orient: Int) = { val t = pos.copy.multiply(1 / 16d).translation - for (i <- 0 until 48) xs(i) = bakeCopy(m.copy.apply(t), i) - xs + bakeCopy(m.copy.apply(t), orient) } def getUVT: UVTransformation From 941f1414a07ab96d8c101fab0bc3a7702c3f90dd Mon Sep 17 00:00:00 2001 From: AnsonYeung Date: Wed, 22 Apr 2026 01:22:12 +0800 Subject: [PATCH 2/6] Revert "compute on the fly" This reverts commit 7c234d2b1bae622b83034d6ceec5db804bf14916. --- .../scala/mrtjp/projectred/integration/components.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/scala/mrtjp/projectred/integration/components.scala b/src/main/scala/mrtjp/projectred/integration/components.scala index a401a4bce..331024e06 100644 --- a/src/main/scala/mrtjp/projectred/integration/components.scala +++ b/src/main/scala/mrtjp/projectred/integration/components.scala @@ -241,9 +241,11 @@ abstract class ComponentModel { abstract class SingleComponentModel(m: CCModel, pos: Vector3 = Vector3.zero) extends ComponentModel { - def models(orient: Int) = { + val models = { + val xs = new Array[CCModel](48) val t = pos.copy.multiply(1 / 16d).translation - bakeCopy(m.copy.apply(t), orient) + for (i <- 0 until 48) xs(i) = bakeCopy(m.copy.apply(t), i) + xs } def getUVT: UVTransformation From 5936c47647b707d2a578f164dd98045967e22a6b Mon Sep 17 00:00:00 2001 From: AnsonYeung Date: Wed, 22 Apr 2026 02:33:58 +0800 Subject: [PATCH 3/6] Proper fix --- .../projectred/integration/components.scala | 42 +++++++++++-------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/main/scala/mrtjp/projectred/integration/components.scala b/src/main/scala/mrtjp/projectred/integration/components.scala index 331024e06..f5bf7e4ee 100644 --- a/src/main/scala/mrtjp/projectred/integration/components.scala +++ b/src/main/scala/mrtjp/projectred/integration/components.scala @@ -93,6 +93,19 @@ object ComponentStore { var icChipIconOff: IIcon = null var icHousingIcon: IIcon = null + val orientPrecomputed = (0 until 48).map(orientT).toArray + val bundledCablePrecomputed = (0 until 48).map((orient: Int) => { + val side = orient % 24 >> 2 + val r = orient & 3 + val reflect = orient >= 24 + val rotate = (r + WireModelGen.reorientSide(side)) % 4 >= 2 + + var t: Transformation = new RedundantTransformation + if (reflect) t = t.`with`(new Scale(-1, 0, 1)) + if (rotate) t = t.`with`(Rotation.quarterRotations(2)) + t + }).toArray + def registerIcons(reg: IIconRegister) { val baseTex = "projectred:integration/" def register(path: String) = reg.registerIcon(baseTex + path) @@ -241,17 +254,18 @@ abstract class ComponentModel { abstract class SingleComponentModel(m: CCModel, pos: Vector3 = Vector3.zero) extends ComponentModel { - val models = { - val xs = new Array[CCModel](48) + // instead of creating 48 models, only make 2 (original + vertex flipped) + val model_pair = { val t = pos.copy.multiply(1 / 16d).translation - for (i <- 0 until 48) xs(i) = bakeCopy(m.copy.apply(t), i) - xs + bakeDynamic(m.copy.apply(t)) } + def extraTransformModel(orient: Int): Transformation = orientPrecomputed(orient) + def getUVT: UVTransformation override def renderModel(t: Transformation, orient: Int) { - models(orient).render(t, getUVT) + model_pair(if (orient < 24) 0 else 1).render(new TransformationList(extraTransformModel(orient), t), getUVT) } } @@ -608,19 +622,11 @@ abstract class BundledCableModel( uCenter: Double, vCenter: Double ) extends SingleComponentModel(model, pos) { - for (orient <- 0 until 48) { - val side = orient % 24 >> 2 - val r = orient & 3 - val reflect = orient >= 24 - val rotate = (r + WireModelGen.reorientSide(side)) % 4 >= 2 - - var t: Transformation = new RedundantTransformation - if (reflect) t = t.`with`(new Scale(-1, 0, 1)) - if (rotate) t = t.`with`(Rotation.quarterRotations(2)) - - if (!t.isInstanceOf[RedundantTransformation]) - models(orient).apply(new UVT(t.at(new Vector3(uCenter, 0, vCenter)))) - } + private val newTransforms = (0 until 48).map((orient: Int) =>{ + val t = bundledCablePrecomputed(orient) + new TransformationList(super.extraTransformModel(orient), t.at(new Vector3(uCenter, 0, vCenter))) + }) + override def extraTransformModel(orient: Int): Transformation = newTransforms(orient) } class BusXcvrCableModel From f416ae4b1efa6022a446371be1d2e4aea9319802 Mon Sep 17 00:00:00 2001 From: AnsonYeung Date: Wed, 22 Apr 2026 20:18:49 +0800 Subject: [PATCH 4/6] Apply the light model --- src/main/scala/mrtjp/projectred/integration/components.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/mrtjp/projectred/integration/components.scala b/src/main/scala/mrtjp/projectred/integration/components.scala index f5bf7e4ee..6ddf67a03 100644 --- a/src/main/scala/mrtjp/projectred/integration/components.scala +++ b/src/main/scala/mrtjp/projectred/integration/components.scala @@ -254,7 +254,7 @@ abstract class ComponentModel { abstract class SingleComponentModel(m: CCModel, pos: Vector3 = Vector3.zero) extends ComponentModel { - // instead of creating 48 models, only make 2 (original + vertex flipped) + // instead of creating 48 models, only make 2 (original + flipped orientation) val model_pair = { val t = pos.copy.multiply(1 / 16d).translation bakeDynamic(m.copy.apply(t)) @@ -265,7 +265,7 @@ abstract class SingleComponentModel(m: CCModel, pos: Vector3 = Vector3.zero) def getUVT: UVTransformation override def renderModel(t: Transformation, orient: Int) { - model_pair(if (orient < 24) 0 else 1).render(new TransformationList(extraTransformModel(orient), t), getUVT) + model_pair(if (orient < 24) 0 else 1).render(new TransformationList(extraTransformModel(orient), t), getUVT, LightModel.standardLightModel) } } From 42efff1fd3511cb9fe8b90d64cd94e74f8b434b0 Mon Sep 17 00:00:00 2001 From: AnsonYeung Date: Wed, 22 Apr 2026 20:20:02 +0800 Subject: [PATCH 5/6] spotlessApply --- .../projectred/integration/components.scala | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/src/main/scala/mrtjp/projectred/integration/components.scala b/src/main/scala/mrtjp/projectred/integration/components.scala index 6ddf67a03..6ec678ae6 100644 --- a/src/main/scala/mrtjp/projectred/integration/components.scala +++ b/src/main/scala/mrtjp/projectred/integration/components.scala @@ -94,17 +94,19 @@ object ComponentStore { var icHousingIcon: IIcon = null val orientPrecomputed = (0 until 48).map(orientT).toArray - val bundledCablePrecomputed = (0 until 48).map((orient: Int) => { - val side = orient % 24 >> 2 - val r = orient & 3 - val reflect = orient >= 24 - val rotate = (r + WireModelGen.reorientSide(side)) % 4 >= 2 - - var t: Transformation = new RedundantTransformation - if (reflect) t = t.`with`(new Scale(-1, 0, 1)) - if (rotate) t = t.`with`(Rotation.quarterRotations(2)) - t - }).toArray + val bundledCablePrecomputed = (0 until 48) + .map((orient: Int) => { + val side = orient % 24 >> 2 + val r = orient & 3 + val reflect = orient >= 24 + val rotate = (r + WireModelGen.reorientSide(side)) % 4 >= 2 + + var t: Transformation = new RedundantTransformation + if (reflect) t = t.`with`(new Scale(-1, 0, 1)) + if (rotate) t = t.`with`(Rotation.quarterRotations(2)) + t + }) + .toArray def registerIcons(reg: IIconRegister) { val baseTex = "projectred:integration/" @@ -260,12 +262,18 @@ abstract class SingleComponentModel(m: CCModel, pos: Vector3 = Vector3.zero) bakeDynamic(m.copy.apply(t)) } - def extraTransformModel(orient: Int): Transformation = orientPrecomputed(orient) + def extraTransformModel(orient: Int): Transformation = orientPrecomputed( + orient + ) def getUVT: UVTransformation override def renderModel(t: Transformation, orient: Int) { - model_pair(if (orient < 24) 0 else 1).render(new TransformationList(extraTransformModel(orient), t), getUVT, LightModel.standardLightModel) + model_pair(if (orient < 24) 0 else 1).render( + new TransformationList(extraTransformModel(orient), t), + getUVT, + LightModel.standardLightModel + ) } } @@ -622,11 +630,16 @@ abstract class BundledCableModel( uCenter: Double, vCenter: Double ) extends SingleComponentModel(model, pos) { - private val newTransforms = (0 until 48).map((orient: Int) =>{ + private val newTransforms = (0 until 48).map((orient: Int) => { val t = bundledCablePrecomputed(orient) - new TransformationList(super.extraTransformModel(orient), t.at(new Vector3(uCenter, 0, vCenter))) + new TransformationList( + super.extraTransformModel(orient), + t.at(new Vector3(uCenter, 0, vCenter)) + ) }) - override def extraTransformModel(orient: Int): Transformation = newTransforms(orient) + override def extraTransformModel(orient: Int): Transformation = newTransforms( + orient + ) } class BusXcvrCableModel From e2fecc32e43874150d0064b33c09a14746b813b5 Mon Sep 17 00:00:00 2001 From: AnsonYeung Date: Wed, 22 Apr 2026 21:14:14 +0800 Subject: [PATCH 6/6] Change naming --- src/main/scala/mrtjp/projectred/integration/components.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/mrtjp/projectred/integration/components.scala b/src/main/scala/mrtjp/projectred/integration/components.scala index 6ec678ae6..331b25830 100644 --- a/src/main/scala/mrtjp/projectred/integration/components.scala +++ b/src/main/scala/mrtjp/projectred/integration/components.scala @@ -257,7 +257,7 @@ abstract class ComponentModel { abstract class SingleComponentModel(m: CCModel, pos: Vector3 = Vector3.zero) extends ComponentModel { // instead of creating 48 models, only make 2 (original + flipped orientation) - val model_pair = { + private val modelPair = { val t = pos.copy.multiply(1 / 16d).translation bakeDynamic(m.copy.apply(t)) } @@ -269,7 +269,7 @@ abstract class SingleComponentModel(m: CCModel, pos: Vector3 = Vector3.zero) def getUVT: UVTransformation override def renderModel(t: Transformation, orient: Int) { - model_pair(if (orient < 24) 0 else 1).render( + modelPair(if (orient < 24) 0 else 1).render( new TransformationList(extraTransformModel(orient), t), getUVT, LightModel.standardLightModel