Package com.jme3.animation
Class CompactArray<T>
java.lang.Object
com.jme3.animation.CompactArray<T>
- Type Parameters:
T- the type of object (i.e. Vector3f)
- All Implemented Interfaces:
JmeCloneable,Cloneable
- Direct Known Subclasses:
CompactFloatArray,CompactQuaternionArray,CompactVector3Array
Object is indexed and stored in primitive float[]
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a compact arrayCompactArray(float[] compressedArray, int[] index) create array using serialized data -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd objects.clone()Create a deep clone of this array.voidcloneFields(Cloner cloner, Object original) Callback fromClonerto convert this shallow-cloned array into a deep-cloned one, using the specified cloner to resolve copied fields.protected abstract Tdeserialize(int compactIndex, T store) deserialize objectprotected float[]ensureCapacity(float[] arr, int size) Ensure the capacity for the given array and the given sizevoidfreeze()release objects.final Treturns the object for the given indexintgetCompactIndex(int objIndex) returns the corresponding index in the compact arrayfinal intfinal int[]Return an array of indices for the given objectsfinal float[]return a float array of serialized dataprotected final intfinal intprotected abstract intserialized size of one object elementjmeClone()Create a shallow clone for the JME cloner.final voidserialize this compact arrayprotected abstract voidserialize objectfinal voidprotected voidsetInvalid(boolean invalid) final T[]decompress and return object array
-
Field Details
-
indexPool
-
index
protected int[] index -
array
protected float[] array
-
-
Constructor Details
-
CompactArray
public CompactArray()Creates a compact array -
CompactArray
public CompactArray(float[] compressedArray, int[] index) create array using serialized data- Parameters:
compressedArray- storage for float dataindex- storage for indices
-
-
Method Details
-
add
Add objects. They are serialized automatically when get() method is called.- Parameters:
objArray- the objects to be added (may be null)
-
freeze
public void freeze()release objects. add() method call is not allowed anymore. -
setInvalid
protected void setInvalid(boolean invalid) -
set
- Parameters:
index- zero-origin index of the element to be alteredvalue- the desired value
-
get
returns the object for the given index- Parameters:
index- the indexstore- an object to store the result- Returns:
- an element
-
getSerializedData
public final float[] getSerializedData()return a float array of serialized data- Returns:
- the pre-existing array
-
serialize
public final void serialize()serialize this compact array -
getSerializedSize
protected final int getSerializedSize()- Returns:
- compacted array's primitive size
-
ensureCapacity
protected float[] ensureCapacity(float[] arr, int size) Ensure the capacity for the given array and the given size- Parameters:
arr- the arraysize- the size- Returns:
- an array
-
getIndex
Return an array of indices for the given objects- Parameters:
objArray- the input objects- Returns:
- a new array
-
getCompactIndex
public int getCompactIndex(int objIndex) returns the corresponding index in the compact array- Parameters:
objIndex- the input index- Returns:
- object index in the compacted object array
-
getTotalObjectSize
public final int getTotalObjectSize()- Returns:
- uncompressed object size
-
getCompactObjectSize
public final int getCompactObjectSize()- Returns:
- compressed object size
-
toObjectArray
decompress and return object array- Returns:
- decompress and return object array
-
clone
Create a deep clone of this array.- Overrides:
clonein classObject- Returns:
- a new array
- Throws:
CloneNotSupportedException- never
-
jmeClone
Create a shallow clone for the JME cloner.- Specified by:
jmeClonein interfaceJmeCloneable- Returns:
- a new array
-
cloneFields
Callback fromClonerto convert this shallow-cloned array into a deep-cloned one, using the specified cloner to resolve copied fields.- Specified by:
cloneFieldsin interfaceJmeCloneable- Parameters:
cloner- the cloner currently cloning this control (not null)original- the array from which this array was shallow-cloned (unused)
-
serialize
serialize object- Parameters:
compactIndex- compacted object indexstore- the value to be serialized (not null, unaffected)
-
deserialize
deserialize object- Parameters:
compactIndex- compacted object indexstore- storage for the result- Returns:
- the deserialized value
-
getTupleSize
protected abstract int getTupleSize()serialized size of one object element- Returns:
- the number of primitive components (floats) per object
-
getElementClass
-