From d7db823fa16791b5e63db968dc2f2298c1644746 Mon Sep 17 00:00:00 2001 From: Dave Hoover Date: Sat, 5 Dec 2009 00:55:49 +0000 Subject: [PATCH] I'm in ur nenya breaking ur api We hit a wall in yohoho where we really needed 3 colors on a scene object. Turns out that colorizations are restricted to 255 even though we stuff it in a short, and even WE are only up to mid 50s or so with our zations, so forcing it into a byte hopefully won't pain anybody else that happens to be using this code. So we add the ability to have tertiary and quaternary zations on miso objects while keeping backwards compatability by slotting our two new bytes into unused space. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@867 ed5b42cb-e716-0410-a449-f6a68f950b19 --- .../threerings/media/image/ColorPository.java | 10 ++++++-- .../com/threerings/miso/data/ObjectInfo.java | 24 +++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/java/com/threerings/media/image/ColorPository.java b/src/java/com/threerings/media/image/ColorPository.java index cb68db55..c617cdcd 100644 --- a/src/java/com/threerings/media/image/ColorPository.java +++ b/src/java/com/threerings/media/image/ColorPository.java @@ -23,6 +23,7 @@ package com.threerings.media.image; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.io.File; @@ -86,8 +87,8 @@ public class ColorPository implements Serializable public void addColor (ColorRecord record) { // validate the color id - if (record.colorId > 255) { - log.warning("Refusing to add color record; colorId > 255", + if (record.colorId > 127) { + log.warning("Refusing to add color record; colorId > 127", "class", this, "record", record); } else { record.cclass = this; @@ -251,6 +252,11 @@ public class ColorPository implements Serializable return _classes.values().iterator(); } + public Collection getClasses () + { + return _classes.values(); + } + /** * Returns an array containing the records for the colors in the * specified class. diff --git a/src/java/com/threerings/miso/data/ObjectInfo.java b/src/java/com/threerings/miso/data/ObjectInfo.java index 05c6239d..8e5df9c2 100644 --- a/src/java/com/threerings/miso/data/ObjectInfo.java +++ b/src/java/com/threerings/miso/data/ObjectInfo.java @@ -103,7 +103,7 @@ public class ObjectInfo extends SimpleStreamableObject */ public int getPrimaryZation () { - return (zations & 0xFFFF); + return (zations & 0xFF); } /** @@ -111,15 +111,31 @@ public class ObjectInfo extends SimpleStreamableObject */ public int getSecondaryZation () { - return ((zations >> 16) & 0xFFFF); + return ((zations >> 16) & 0xFF); + } + + /** + * Returns the tertiary colorization assignment. + */ + public int getTertiaryZation () + { + return ((zations >> 24) & 0xFF); + } + + /** + * Returns the quaternary colorization assignment. + */ + public int getQuaternaryZation () + { + return ((zations >> 8) & 0xFF); } /** * Sets the primary and secondary colorization assignments. */ - public void setZations (short primary, short secondary) + public void setZations (byte primary, byte secondary, byte tertiary, byte quaternary) { - zations = ((secondary << 16) | primary); + zations = (primary | (secondary << 16) | (tertiary << 24) | (quaternary << 8)); } /**