mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-20 20:22:15 +00:00
refactor: port micro occlusion to Java
This commit is contained in:
1 parent
f57f52408b
commit
34aeb7c0d3
7 files changed
+317
-161
No files matched your search
@@ -1193,3 +1193,12 @@ generated-trait compatibility work. Scala-runtime removal remains a later projec
|
||||
- A clean build passes all 252 plain-JVM tests and the Java 8 Forge server passes all 110 tests. All nine supported
|
||||
public surfaces match the reference; both retained trait helpers and all seven trait closures are bytecode-identical.
|
||||
Only three private factory table-initializer closures disappear. `microblock/TMicroOcclusion.scala` is next.
|
||||
- Characterized `MicroOcclusion` against untouched Scala. Five plain-JVM cases freeze the facade, companion, three
|
||||
generated-trait surfaces, all valid shrink-side mappings, exhaustive priority/size/transparency decisions, render
|
||||
masks, traversal ranges and the complete `TMicroOcclusion` decision matrix.
|
||||
- Ported only the concrete facade and companion to Java. `JMicroShrinkRender`, `TMicroOcclusion` and the stateful
|
||||
`TMicroOcclusionClient` remain Scala; both trait helpers and all five retained Scala types have bytecode-identical
|
||||
disassembly. Direct Java iteration removes the sole private shrink closure.
|
||||
- A clean build passes all 257 plain-JVM tests and the Java 8 Forge server passes all 110 tests. All seven supported
|
||||
public surfaces and WR-CBE's static `recalcBounds` descriptor match the reference. `microblock/MicroblockGenerator.scala`
|
||||
is next.
|
||||
@@ -2954,3 +2954,46 @@ identical `javap -c -p -s` output after the port.
|
||||
- Raw `javap` comparison confirms identical callable public names/descriptors for all nine supported types, the exact
|
||||
nested-grid relationship, and bytecode-identical retained trait helpers and closures.
|
||||
- Actual client rendering, breaking overlay and hollow highlight geometry remain on the manual checklist.
|
||||
|
||||
## 2026-09-02 — Micro occlusion Java port
|
||||
|
||||
The concrete `MicroOcclusion` facade and companion are now Java. `JMicroShrinkRender`, `TMicroOcclusion` and the
|
||||
stateful `TMicroOcclusionClient` remain Scala in `TMicroOcclusion.scala`, preserving their generated-trait,
|
||||
super-accessor and mutable render-state surfaces without involving the generator.
|
||||
|
||||
### Observable behavior
|
||||
|
||||
No known runtime divergence. Axis shrink remains non-expanding and keeps `-1` as a no-op. Shape priority remains
|
||||
cover, corner, then edge/post; priority class, size, transparency and slot tie-breaking retain their original order,
|
||||
including transparency taking precedence over size only for covers. Every valid face/corner/edge `shrinkSide`
|
||||
mapping is unchanged.
|
||||
|
||||
`shrinkFrom` still either contracts the render bounds or masks a fully covered opaque face. Recalculation still
|
||||
visits slots 0 through 5 for covers, 0 through 14 for corners, and 0 through 26 for edges/posts. The original Scala
|
||||
`TMicroOcclusion` material, size, opposite-part and edge/corner decisions are unchanged.
|
||||
|
||||
### ABI and reflection compatibility
|
||||
|
||||
All seven supported facade, companion, trait and `$class` types keep their hierarchy and callable public
|
||||
names/descriptors. WR-CBE's load-bearing static
|
||||
`MicroOcclusion.recalcBounds(JMicroShrinkRender, Cuboid6): int` call remains exact, as does the
|
||||
`JMicroShrinkRender` interface. The downstream inventory contains no references to the private implementation
|
||||
closure or trait helpers.
|
||||
|
||||
The five retained Scala types and helpers have bytecode-identical `javap -p -c -s` output. Accepted classfile-only
|
||||
differences in the two Java types are ordinary Java singleton initialization, constructors and removed Scala
|
||||
signature/marker attributes.
|
||||
|
||||
### Compiler artifacts
|
||||
|
||||
`MicroOcclusion$$anonfun$shrink$1` disappears. Direct Java slot iteration needs no closure, and the downstream
|
||||
inventory contains no reference to it.
|
||||
|
||||
### Validation
|
||||
|
||||
- `MicroOcclusionCharacterizationTest`: 5 plain-JVM tests, unchanged from the Scala baseline.
|
||||
- Clean complete plain-JVM suite: 257 tests, 0 failures, 0 errors.
|
||||
- Java 8 Forge dedicated-server suite: 110 tests, 0 failures, 0 errors.
|
||||
- Raw `javap` comparison confirms identical callable public names/descriptors for all seven supported types and
|
||||
bytecode-identical retained trait/helper disassembly.
|
||||
- Actual neighbour-driven shrink and render-bound refresh remain on the manual checklist.
|
||||
@@ -12,8 +12,8 @@ what breaks, and what is left. The other documents hold the reasoning.
|
||||
| `JAVA_MIGRATION_MANUAL_CHECKS.md` | What no automated test can cover, and must be checked by hand in a client |
|
||||
| `JAVA_MIGRATION_PROFILE.md` | The focused baseline, first measured result, findings, and exact rerun command |
|
||||
|
||||
Branch: `algent/java`. Base: `master`. 144 commits including the API-cleanup plan and separate characterization and
|
||||
port commits through the Hollow microblock factory.
|
||||
Branch: `algent/java`. Base: `master`. 146 commits including the API-cleanup plan and separate characterization and
|
||||
port commits through micro occlusion.
|
||||
|
||||
## The one rule that matters
|
||||
|
||||
@@ -67,7 +67,7 @@ awk -F'"' '/<testsuite /{t+=$4;f+=$8;e+=$10} END{print "tests="t" failures="f" e
|
||||
grep -o 'tests="[0-9]*" skipped="[0-9]*" failures="[0-9]*" errors="[0-9]*"' run/server/junit-out/TEST-*.xml
|
||||
```
|
||||
|
||||
Current baseline: **252 plain-JVM tests and 110 Java 8 Forge dedicated-server tests passing.** The ignored local server
|
||||
Current baseline: **257 plain-JVM tests and 110 Java 8 Forge dedicated-server tests passing.** The ignored local server
|
||||
EULA is accepted in this checkout. GitHub Actions runs the same self-validating Forge suite in a dependent job after
|
||||
the shared GTNH build; keep both jobs required.
|
||||
|
||||
@@ -520,9 +520,16 @@ Both trait helpers and all seven retained geometry/render closures are bytecode-
|
||||
three private table-initializer closures disappear. ProjectRed's trait checks and static class-ID call, Extra
|
||||
Utilities' two client-trait checks, and BuildCraft/MatterManipulator's stable `"mcr_hllw"` ID remain exact.
|
||||
|
||||
**High.** `TMicroOcclusion.scala` is next. Freeze the complete shrink/priority math and all generated trait/helper
|
||||
surfaces before splitting only the concrete `MicroOcclusion` facade/companion logic. Keep `JMicroShrinkRender`,
|
||||
`TMicroOcclusion`, and the stateful `TMicroOcclusionClient` Scala, and do not combine this with generator work.
|
||||
The micro-occlusion source unit is now two Java facade/companion sources plus three retained Scala traits. Five
|
||||
plain-JVM cases freeze all seven supported surfaces, every valid shrink-side mapping, exhaustive priority, size and
|
||||
transparency decisions, render masks, traversal ranges and the complete trait decision matrix. All retained Scala
|
||||
trait/helper disassembly is bytecode-identical; only the private shrink traversal closure disappears. WR-CBE's
|
||||
load-bearing static `MicroOcclusion.recalcBounds(JMicroShrinkRender, Cuboid6)` call remains exact.
|
||||
|
||||
**High.** `MicroblockGenerator.scala` is next. Freeze its inherited `ASMMixinFactory`/`ScratchBitSet` singleton,
|
||||
nested `IGeneratedMaterial` Scala trait, exact companion/reflection surface and fresh trait-bit selection before
|
||||
choosing the smallest safe split. ProjectRed exercises external Scala-trait generation and GuideNH pins the exact
|
||||
`create(MicroblockClass, int, boolean)` companion method. Do not combine this with `MultipartGenerator` or ASM work.
|
||||
|
||||
**Phase 5 is complete.** There are no Scala files left in `multipart/scalatraits/`. The client pair required the first
|
||||
narrow generator relaxation: Java-trait parent linearization, explicit field-accessor recognition, and exclusion of
|
||||
|
||||
@@ -32,6 +32,7 @@ below its table.
|
||||
| [ ] | Inspect face, hollow, edge and corner microblocks in inventory and as dropped entities | Every size/material combination uses the correct localized name and centered shape/material render | `ItemMicroPart` / `ItemMicroPartRenderer` / `MicroblockRender.renderItem` |
|
||||
| [ ] | Place crossing posts of different sizes/transparency beside face covers, then add and remove neighbours | Post segments shrink and split at intersections without missing sections or stale render bounds | `PostMicroblockClient.recalcBounds` / `shrinkFace` / `shrinkPost` |
|
||||
| [ ] | Run centre pipes/cables with several connection widths through hollow covers on all six faces, including glass | Each opening follows the connector size; opaque and transparent rims, breaking overlay and highlight have no missing, doubled or stale sections after neighbour changes | `HollowMicroblockClient.recalcBounds` / `renderHollow` / `drawBreaking` / `drawHighlight` |
|
||||
| [ ] | Place touching face, corner and edge microblocks of mixed sizes/transparency, then add and remove neighbours | Intersections choose the same winner, opaque covered faces stay masked, and every surviving segment refreshes without gaps or stale bounds | `MicroOcclusion` / `TMicroOcclusionClient.recalcBounds` |
|
||||
|
||||
## Placement and interaction
|
||||
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
package codechicken.microblock;
|
||||
|
||||
import static codechicken.multipart.PartMap.edgeAxisMask;
|
||||
import static codechicken.multipart.PartMap.unpackEdgeBits;
|
||||
|
||||
import codechicken.lib.vec.Cuboid6;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
import scala.MatchError;
|
||||
|
||||
public final class MicroOcclusion$ {
|
||||
|
||||
public static final MicroOcclusion$ MODULE$ = new MicroOcclusion$();
|
||||
|
||||
private MicroOcclusion$() {}
|
||||
|
||||
public void shrink(Cuboid6 renderBounds, Cuboid6 bounds, int side) {
|
||||
switch (side) {
|
||||
case -1:
|
||||
return;
|
||||
case 0:
|
||||
if (renderBounds.min.y < bounds.max.y) {
|
||||
renderBounds.min.y = bounds.max.y;
|
||||
}
|
||||
return;
|
||||
case 1:
|
||||
if (renderBounds.max.y > bounds.min.y) {
|
||||
renderBounds.max.y = bounds.min.y;
|
||||
}
|
||||
return;
|
||||
case 2:
|
||||
if (renderBounds.min.z < bounds.max.z) {
|
||||
renderBounds.min.z = bounds.max.z;
|
||||
}
|
||||
return;
|
||||
case 3:
|
||||
if (renderBounds.max.z > bounds.min.z) {
|
||||
renderBounds.max.z = bounds.min.z;
|
||||
}
|
||||
return;
|
||||
case 4:
|
||||
if (renderBounds.min.x < bounds.max.x) {
|
||||
renderBounds.min.x = bounds.max.x;
|
||||
}
|
||||
return;
|
||||
case 5:
|
||||
if (renderBounds.max.x > bounds.min.x) {
|
||||
renderBounds.max.x = bounds.min.x;
|
||||
}
|
||||
return;
|
||||
default:
|
||||
throw new MatchError(side);
|
||||
}
|
||||
}
|
||||
|
||||
public int shrinkFrom(JMicroShrinkRender part, JMicroShrinkRender other, Cuboid6 renderBounds) {
|
||||
if (shrinkTest(part, other)) {
|
||||
shrink(renderBounds, other.getBounds(), shrinkSide(part.getSlot(), other.getSlot()));
|
||||
} else if (other.getSlot() < 6 && !other.isTransparent()) {
|
||||
boolean coversFace;
|
||||
switch (other.getSlot()) {
|
||||
case 0:
|
||||
coversFace = renderBounds.min.y <= 0;
|
||||
break;
|
||||
case 1:
|
||||
coversFace = renderBounds.max.y >= 1;
|
||||
break;
|
||||
case 2:
|
||||
coversFace = renderBounds.min.z <= 0;
|
||||
break;
|
||||
case 3:
|
||||
coversFace = renderBounds.max.z >= 1;
|
||||
break;
|
||||
case 4:
|
||||
coversFace = renderBounds.min.x <= 0;
|
||||
break;
|
||||
case 5:
|
||||
coversFace = renderBounds.max.x >= 1;
|
||||
break;
|
||||
default:
|
||||
throw new MatchError(other.getSlot());
|
||||
}
|
||||
if (coversFace) {
|
||||
return 1 << other.getSlot();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int shrink(JMicroShrinkRender part, Cuboid6 renderBounds, int slots) {
|
||||
int renderMask = 0;
|
||||
TileMultipart tile = ((TMultiPart) part).tile();
|
||||
for (int slot = 0; slot < slots; slot++) {
|
||||
if (slot != part.getSlot()) {
|
||||
TMultiPart other = tile.partMap(slot);
|
||||
if (other instanceof JMicroShrinkRender) {
|
||||
renderMask |= shrinkFrom(part, (JMicroShrinkRender) other, renderBounds);
|
||||
}
|
||||
}
|
||||
}
|
||||
return renderMask;
|
||||
}
|
||||
|
||||
public int shrinkSide(int firstSlot, int secondSlot) {
|
||||
if (secondSlot < 6) {
|
||||
return secondSlot;
|
||||
}
|
||||
if (firstSlot < 15) {
|
||||
int firstCorner = firstSlot - 7;
|
||||
int secondCorner = secondSlot - 7;
|
||||
switch (firstCorner ^ secondCorner) {
|
||||
case 1:
|
||||
return secondCorner & 1;
|
||||
case 2:
|
||||
return 2 | (secondCorner & 2) >> 1;
|
||||
case 4:
|
||||
return 4 | (secondCorner & 4) >> 2;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (secondSlot < 15) {
|
||||
int firstEdge = firstSlot - 15;
|
||||
int secondCorner = secondSlot - 7;
|
||||
int edgeBits = unpackEdgeBits(firstEdge);
|
||||
if ((secondCorner & edgeAxisMask(firstEdge)) != edgeBits) {
|
||||
return -1;
|
||||
}
|
||||
return (firstEdge & 0xC) >> 1 | (secondCorner & ~edgeBits) >> (firstEdge >> 2);
|
||||
}
|
||||
|
||||
int firstEdge = firstSlot - 15;
|
||||
int secondEdge = secondSlot - 15;
|
||||
int firstBits = unpackEdgeBits(firstEdge);
|
||||
int secondBits = unpackEdgeBits(secondEdge);
|
||||
if ((firstEdge & 0xC) == (secondEdge & 0xC)) {
|
||||
switch (firstBits ^ secondBits) {
|
||||
case 1:
|
||||
return (secondBits & 1) == 0 ? 0 : 1;
|
||||
case 2:
|
||||
return (secondBits & 2) == 0 ? 2 : 3;
|
||||
case 4:
|
||||
return (secondBits & 4) == 0 ? 4 : 5;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int mask = edgeAxisMask(firstEdge) & edgeAxisMask(secondEdge);
|
||||
if ((firstBits & mask) != (secondBits & mask)) {
|
||||
return -1;
|
||||
}
|
||||
switch (firstEdge >> 2) {
|
||||
case 0:
|
||||
return (secondBits & 1) == 0 ? 0 : 1;
|
||||
case 1:
|
||||
return (secondBits & 2) == 0 ? 2 : 3;
|
||||
case 2:
|
||||
return (secondBits & 4) == 0 ? 4 : 5;
|
||||
default:
|
||||
throw new IllegalArgumentException("Switch Falloff");
|
||||
}
|
||||
}
|
||||
|
||||
public int recalcBounds(JMicroShrinkRender part, Cuboid6 renderBounds) {
|
||||
if (part.getSlot() < 6) {
|
||||
return shrink(part, renderBounds, 6);
|
||||
}
|
||||
if (part.getSlot() < 15) {
|
||||
return shrink(part, renderBounds, 15);
|
||||
}
|
||||
return shrink(part, renderBounds, 27);
|
||||
}
|
||||
|
||||
public int shapePriority(int slot) {
|
||||
if (slot < 6) {
|
||||
return 2;
|
||||
}
|
||||
if (slot < 15) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean shrinkTest(JMicroShrinkRender first, JMicroShrinkRender second) {
|
||||
if (first.getPriorityClass() != second.getPriorityClass()) {
|
||||
return first.getPriorityClass() < second.getPriorityClass();
|
||||
}
|
||||
|
||||
int firstShape = shapePriority(first.getSlot());
|
||||
int secondShape = shapePriority(second.getSlot());
|
||||
if (firstShape != secondShape) {
|
||||
return firstShape < secondShape;
|
||||
}
|
||||
if (first.getSlot() < 6) {
|
||||
if (first.isTransparent() != second.isTransparent()) {
|
||||
return first.isTransparent();
|
||||
}
|
||||
if (first.getSize() != second.getSize()) {
|
||||
return first.getSize() < second.getSize();
|
||||
}
|
||||
} else {
|
||||
if (first.getSize() != second.getSize()) {
|
||||
return first.getSize() < second.getSize();
|
||||
}
|
||||
if (first.isTransparent() != second.isTransparent()) {
|
||||
return first.isTransparent();
|
||||
}
|
||||
}
|
||||
return first.getSlot() < second.getSlot();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package codechicken.microblock;
|
||||
|
||||
import codechicken.lib.vec.Cuboid6;
|
||||
|
||||
public final class MicroOcclusion {
|
||||
|
||||
private MicroOcclusion() {}
|
||||
|
||||
public static void shrink(Cuboid6 renderBounds, Cuboid6 bounds, int side) {
|
||||
MicroOcclusion$.MODULE$.shrink(renderBounds, bounds, side);
|
||||
}
|
||||
|
||||
public static int shrinkFrom(JMicroShrinkRender part, JMicroShrinkRender other, Cuboid6 renderBounds) {
|
||||
return MicroOcclusion$.MODULE$.shrinkFrom(part, other, renderBounds);
|
||||
}
|
||||
|
||||
public static int shrink(JMicroShrinkRender part, Cuboid6 renderBounds, int slots) {
|
||||
return MicroOcclusion$.MODULE$.shrink(part, renderBounds, slots);
|
||||
}
|
||||
|
||||
public static int shrinkSide(int firstSlot, int secondSlot) {
|
||||
return MicroOcclusion$.MODULE$.shrinkSide(firstSlot, secondSlot);
|
||||
}
|
||||
|
||||
public static int recalcBounds(JMicroShrinkRender part, Cuboid6 renderBounds) {
|
||||
return MicroOcclusion$.MODULE$.recalcBounds(part, renderBounds);
|
||||
}
|
||||
|
||||
public static int shapePriority(int slot) {
|
||||
return MicroOcclusion$.MODULE$.shapePriority(slot);
|
||||
}
|
||||
|
||||
public static boolean shrinkTest(JMicroShrinkRender first, JMicroShrinkRender second) {
|
||||
return MicroOcclusion$.MODULE$.shrinkTest(first, second);
|
||||
}
|
||||
}
|
||||
@@ -5,156 +5,6 @@ import codechicken.lib.vec.Cuboid6
|
||||
import codechicken.multipart.PartMap._
|
||||
import codechicken.lib.data.MCDataInput
|
||||
|
||||
/** Suite of classes for performing microblock style occlusion and shrink
|
||||
* rendering. Use at your own peril.
|
||||
*/
|
||||
object MicroOcclusion {
|
||||
def shrink(renderBounds: Cuboid6, b: Cuboid6, side: Int) = side match {
|
||||
case -1 =>
|
||||
case 0 => if (renderBounds.min.y < b.max.y) renderBounds.min.y = b.max.y
|
||||
case 1 => if (renderBounds.max.y > b.min.y) renderBounds.max.y = b.min.y
|
||||
case 2 => if (renderBounds.min.z < b.max.z) renderBounds.min.z = b.max.z
|
||||
case 3 => if (renderBounds.max.z > b.min.z) renderBounds.max.z = b.min.z
|
||||
case 4 => if (renderBounds.min.x < b.max.x) renderBounds.min.x = b.max.x
|
||||
case 5 => if (renderBounds.max.x > b.min.x) renderBounds.max.x = b.min.x
|
||||
}
|
||||
|
||||
def shrinkFrom(
|
||||
p: JMicroShrinkRender,
|
||||
other: JMicroShrinkRender,
|
||||
renderBounds: Cuboid6
|
||||
): Int = {
|
||||
if (shrinkTest(p, other)) {
|
||||
shrink(
|
||||
renderBounds,
|
||||
other.getBounds,
|
||||
shrinkSide(p.getSlot, other.getSlot)
|
||||
)
|
||||
} else if (
|
||||
other.getSlot < 6 && !other.isTransparent
|
||||
) // other gets full face, we didn't shrink, flag rendermask
|
||||
{
|
||||
if (
|
||||
other.getSlot match {
|
||||
case 0 => renderBounds.min.y <= 0
|
||||
case 1 => renderBounds.max.y >= 1
|
||||
case 2 => renderBounds.min.z <= 0
|
||||
case 3 => renderBounds.max.z >= 1
|
||||
case 4 => renderBounds.min.x <= 0
|
||||
case 5 => renderBounds.max.x >= 1
|
||||
}
|
||||
)
|
||||
return 1 << other.getSlot
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
def shrink(p: JMicroShrinkRender, renderBounds: Cuboid6, m: Int): Int = {
|
||||
var renderMask = 0
|
||||
val part = p.asInstanceOf[TMultiPart]
|
||||
val tile = part.tile
|
||||
for (i <- 0 until m)
|
||||
if (i != p.getSlot)
|
||||
tile.partMap(i) match {
|
||||
case other: JMicroShrinkRender =>
|
||||
renderMask |= shrinkFrom(p, other, renderBounds)
|
||||
case _ =>
|
||||
}
|
||||
return renderMask
|
||||
}
|
||||
|
||||
def shrinkSide(s1: Int, s2: Int): Int = {
|
||||
if (s2 < 6) // other is a cover
|
||||
return s2
|
||||
if (s1 < 15) // both corners
|
||||
{
|
||||
val c1 = s1 - 7
|
||||
val c2 = s2 - 7
|
||||
return c1 ^ c2 match // different axis bits will become 1, same 0
|
||||
{
|
||||
case 1 => c2 & 1
|
||||
case 2 => 2 | (c2 & 2) >> 1
|
||||
case 4 => 4 | (c2 & 4) >> 2
|
||||
case _ => -1
|
||||
}
|
||||
}
|
||||
if (s2 < 15) // edge, other corner
|
||||
{
|
||||
val e1 = s1 - 15
|
||||
val c2 = s2 - 7
|
||||
val ebits = unpackEdgeBits(e1)
|
||||
if ((c2 & edgeAxisMask(e1)) != ebits)
|
||||
return -1
|
||||
|
||||
return (e1 & 0xc) >> 1 | (c2 & (~ebits)) >> (e1 >> 2)
|
||||
}
|
||||
// both edges
|
||||
{
|
||||
val e1 = s1 - 15
|
||||
val e2 = s2 - 15
|
||||
val e1bits = unpackEdgeBits(e1)
|
||||
val e2bits = unpackEdgeBits(e2)
|
||||
if ((e1 & 0xc) == (e2 & 0xc)) // same axis
|
||||
{
|
||||
return e1bits ^ e2bits match {
|
||||
case 1 => if ((e2bits & 1) == 0) 0 else 1
|
||||
case 2 => if ((e2bits & 2) == 0) 2 else 3
|
||||
case 4 => if ((e2bits & 4) == 0) 4 else 5
|
||||
case _ => -1
|
||||
}
|
||||
} else {
|
||||
val mask = edgeAxisMask(e1) & edgeAxisMask(e2)
|
||||
if ((e1bits & mask) != (e2bits & mask))
|
||||
return -1
|
||||
|
||||
return e1 >> 2 match {
|
||||
case 0 => if ((e2bits & 1) == 0) 0 else 1
|
||||
case 1 => if ((e2bits & 2) == 0) 2 else 3
|
||||
case 2 => if ((e2bits & 4) == 0) 4 else 5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Switch Falloff")
|
||||
}
|
||||
|
||||
def recalcBounds(p: JMicroShrinkRender, renderBounds: Cuboid6) = {
|
||||
if (p.getSlot < 6)
|
||||
shrink(p, renderBounds, 6)
|
||||
else if (p.getSlot < 15)
|
||||
shrink(p, renderBounds, 15)
|
||||
else
|
||||
shrink(p, renderBounds, 27)
|
||||
}
|
||||
|
||||
def shapePriority(slot: Int): Int =
|
||||
if (slot < 6)
|
||||
return 2
|
||||
else if (slot < 15)
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
|
||||
def shrinkTest(a: JMicroShrinkRender, b: JMicroShrinkRender): Boolean = {
|
||||
if (a.getPriorityClass != b.getPriorityClass)
|
||||
return a.getPriorityClass < b.getPriorityClass
|
||||
|
||||
val shape1 = shapePriority(a.getSlot)
|
||||
val shape2 = shapePriority(b.getSlot)
|
||||
|
||||
if (shape1 != shape2) return shape1 < shape2
|
||||
if (a.getSlot < 6) // transparency takes precedence for covers
|
||||
{
|
||||
if (a.isTransparent != b.isTransparent) return a.isTransparent
|
||||
if (a.getSize != b.getSize) return a.getSize < b.getSize
|
||||
} else {
|
||||
if (a.getSize != b.getSize) return a.getSize < b.getSize
|
||||
if (a.isTransparent != b.isTransparent) return a.isTransparent
|
||||
}
|
||||
return a.getSlot < b.getSlot
|
||||
}
|
||||
}
|
||||
|
||||
trait JMicroShrinkRender {
|
||||
def getPriorityClass: Int
|
||||
def getSlot: Int
|
||||
@@ -184,15 +34,13 @@ trait TMicroOcclusionClient extends TMicroOcclusion with JMicroShrinkRender {
|
||||
|
||||
def recalcBounds() {
|
||||
renderBounds = getBounds.copy
|
||||
renderMask = MicroOcclusion.recalcBounds(this, renderBounds)
|
||||
renderMask = MicroOcclusion$.MODULE$.recalcBounds(this, renderBounds)
|
||||
}
|
||||
|
||||
override def getPriorityClass = 0
|
||||
}
|
||||
|
||||
trait TMicroOcclusion extends TMultiPart {
|
||||
import MicroOcclusion._
|
||||
|
||||
def getSlot: Int
|
||||
def getSize: Int
|
||||
def getMaterial: Int
|
||||
@@ -206,8 +54,8 @@ trait TMicroOcclusion extends TMultiPart {
|
||||
return true
|
||||
|
||||
val mpart = npart.asInstanceOf[TMicroOcclusion]
|
||||
val shape1 = shapePriority(getSlot)
|
||||
val shape2 = shapePriority(mpart.getSlot)
|
||||
val shape1 = MicroOcclusion$.MODULE$.shapePriority(getSlot)
|
||||
val shape2 = MicroOcclusion$.MODULE$.shapePriority(mpart.getSlot)
|
||||
|
||||
if (mpart.getSize + getSize > 8) // intersecting if opposite
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user