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
This commit is contained in:
Dave Hoover
2009-12-05 00:55:49 +00:00
parent b726523cf1
commit d7db823fa1
2 changed files with 28 additions and 6 deletions
@@ -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<ClassRecord> getClasses ()
{
return _classes.values();
}
/**
* Returns an array containing the records for the colors in the
* specified class.
@@ -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));
}
/**