UInt16ConstantArrayAttribute.kl¶
Types¶
GeometryAttributes (object)¶
The GeometryAttributes object is a generic container that contains a named set of GeometryAttribute. Each GeometryAttribute is an array containing values of a specific type. For example, the “positions” attribute is typically a Vec3Attribute containing Vec3 elements.
All Geometry types, such as the PolygonMesh, contain a GeometryAttributes container which can be retrieved using the Geometry.getAttributes interface method. However, it is the geometry that controls the order and meaning of the attribute elements within the GeometryAttribute array. For example, the PolygonMesh maintains information about how the values are shared.
注釈
Attributes needs to be uniquely identified by a name. The GeometryAttributes cannot contain multiple attributes with the same name, even if the type differs.
Attribute versioning¶
In order to allow for optimal performance and multithreading, attributes contain a version number (UInt32) which has to be explicitly incremented after value modifications. However, if the size of the attribute array changes, the version will be automatically incremented. Attribute clients, such as InlineDrawing, can then detect value changes efficiently in order to update their state.
注釈
This versioning strategy favors performance over simplicity. Another choice could have been to automatically increase the version when detecting a value difference. Another could have been to let the clients compare values to their last state using a copy or a hash of the values. However, these would have caused performance overhead that could be relatively important in some situations.
Similarly, the GeometryAttributes.keysVersion member defines a version for the set of attributes, which will get incremented only if attributes get added or removed from the container, but not upon attribute resize or value changes.
Members¶
UInt32 | keysVersion | Version of the attribute set. This is incremented only if attributes are added or removed, and not if values are changed or values array is resized. |
UInt32 | attributesValueVersion | |
Ref<GeometryAttribute> | positionsAttribute | Fast access to the positions attribute, if it exists. Note: might be Vec3Attribute or Vec3_dAttribute depending on the precision. |
Ref<GeometryAttribute> | normalsAttribute | Fast access to normals attribute, if it exists. |
String | debugName | Name to be used by descriptions |
/*
** Example: GeometryAttributes
*/
require Geometry;
function reportAttributes( Geometry geom ) {
// Get the attributes container from the geometry
Ref<GeometryAttributes> attributes = geom.getAttributes();
report('Number of attributes: ' + attributes.attributeCount());
report('Number of elements: ' + attributes.size());
// Iterate over the attributes
GeometryAttributesIterator iter = attributes.getAttributesIterator();
Ref<GeometryAttribute> attribute = null;
while( attribute = iter.getNext() )
report( 'Attribute ' + attribute.getName() + ' of type ' + attribute.type() );
}
operator entry() {
PolygonMesh p();
p.addSphere( Xfo(), 1.0, 3, true, true );
reportAttributes(p);
}
/*
** Output:
Number of attributes: 3
Number of elements: 77
Attribute positions of type Vec3Attribute
Attribute normals of type Vec3Attribute
Attribute uvs0 of type Vec2Attribute
*/
Methods¶
UInt16ConstantArrayAttribute (object)¶
Specialized GeometryAttribute containing a constant sized arrays of UInt16, packed as a single memory buffer. The UInt16ConstantArrayAttribute.setArraySize method sets a constant array size for all values. Values can be accessed with the UInt16ConstantArrayAttribute.values array member, but its usage might be restricted by the owner Geometry.
Members¶
UInt32 | version | |
String | name | |
UInt32 | containerIndex | |
StatisticsAutoRegisterMember | autoStats | |
Size | count | |
Ref<GeometryAttributes> | container | |
UInt16[] | values | Values array container |
Boolean | normalize | If true, values should be interpreted as a 0.0 to 1.0 range (eg: for OpenGL) |
Boolean | canInterpolate | If true, IntegerAttribute.linearCombine and IntegerAttribute.getLinearCombination will average the values. Else, an arbitrary source value will be used. |
Methods¶
UInt16ConstantArrayAttribute ( in UInt16ConstantArrayAttribute other ) | |
UInt16ConstantArrayAttribute () | |
Boolean | checkConsistency ? () |
UInt16ConstantArrayAttribute | clone ? () |
cloneMembersTo ? ( io UInt16ConstantArrayAttribute that ) | |
convertToCPU ! () | |
convertToGPU ! () | |
copyValue ! ( in Ref<Object> sourceAttr, in Size sourceIndex, in Size targetIndex ) | |
copyValue ! ( in Size sourceIndex, in Size targetIndex ) | |
Data | data ? () |
Boolean | equalValues ? ( in Size index1, in Size index2 ) |
UInt16 | get ? ( in Size index, in Size offset ) |
UInt32 | getElementsMemType ? () |
LocalL16UInt16Array | getLinearCombination ? ( in LocalL16UInt32Array sourceIndices, in LocalL16ScalarArray sourceWeights ) |
Size | getScalarValueSize ? () |
linearCombine ! ( in Ref<Object> sourceAttr, in LocalL16UInt32Array sourceIndices, in LocalL16ScalarArray sourceWeights, in Size targetIndex ) | |
resize ! ( in Size count ) | |
setArraySize ! ( in Size arraySize ) | |
setFromScalar ! ( in Size index, in LocalL16ScalarArray value ) | |
setValue ! ( in Size index, in LocalL16UInt16Array value ) | |
String | truncateDecimalsPrint ? ( in Size index, in UInt32 n ) |
String | unitTestPrint ? ( in Size index ) |
String | valueDesc ? ( in Size index ) |