SkinningAttribute (object)

brief The SkinningAttribute contains multiple pairs of id and weight per index. For an index, id-weight pairs can be set one by one or in batch. It provides, too, helpers such as SkinningAttribute.normalize to set weight sum to 1.0. By implementing methods such as GeometryAttribute.LinearCombination, it can properly support modeling operations.

Various strategies are used to lower memory consumption and increase performance:

  • contiguous memory storage in a few buffers to lower memory fragmentation and minimize memory allocations
  • counts per index is implicit if values are appended in order (0 to N-1)
  • ids are stored UInt16, which lowers memory usage and still allows for up to 64K deformer ids

SkinningAttribute SkinningAttribute SkinningAttribute BaseAttribute BaseAttribute SkinningAttribute->BaseAttribute GeometryAttribute GeometryAttribute BaseAttribute->GeometryAttribute StatisticSourceWithAutoRegisterMember StatisticSourceWithAutoRegisterMember BaseAttribute->StatisticSourceWithAutoRegisterMember Versioned Versioned BaseAttribute->Versioned

Members

UInt32 version  
String name  
UInt32 containerIndex  
StatisticsAutoRegisterMember autoStats  
Size count  
Ref<GeometryAttributes> container  
SkinningAttributeData internalData  
UInt32 memoryLocation  
/*
** Example: SkinningAttribute
*/

require Geometry;
  
operator entry() {

  SkinningAttribute skinningAttr = SkinningAttribute();
  
  //Create 2 skinned items
  skinningAttr.resize(2);
  
  //Item 0: 2 id-weight pairs:
  //  pair 0 = [20:0.25]
  //  pair 1 = [21:0.75]
  skinningAttr.setPairCount( 0, 2 );
  skinningAttr.setPair( 0, 0, 20, 0.25 );
  skinningAttr.setPair( 0, 1, 21, 0.75 );
  
  //Item 1: set 3 id-weight pairs in batch = [30:0.5, 31:0.5, 32:0.25]
  LocalL16UInt32Array indices;
  indices.push(30);
  indices.push(31);
  indices.push(32);
  
  LocalL16ScalarArray weights;
  weights.push(0.5);
  weights.push(0.5);
  weights.push(0.25);
  
  skinningAttr.setPairs(1, indices, weights);
  
  Scalar weight;
  UInt16 id;
  for( Size i = 0; i < skinningAttr.getPairCount(0); ++i ) {
    skinningAttr.getPair( 0, i, id, weight );
    report("Item0: pair" + i + ": id="+id+" weight="+weight);
  }
  
  skinningAttr.getPairs(1, indices, weights);
  report("Item1: ids="+indices.getString()+" weights="+weights.getString());
  
  skinningAttr.normalize(0);
  skinningAttr.normalize(1);
  report("Values after normalize:");
  report( skinningAttr.getDesc( true) );
  
}

/*
** Output:

Item0: pair0: id=20 weight=+0.25
Item0: pair1: id=21 weight=+0.75
Item1: ids=[30, 31, 32] weights=[+0.5, +0.5, +0.25]
Values after normalize:
Attribute:  nb elements = 2
  values:[ 
    [20:+0.25, 21:+0.75] 
    [30:+0.400024, 31:+0.400024, 32:+0.200012] 
  ]


*/

Methods

  SkinningAttribute ( in SkinningAttribute other )
  SkinningAttribute ()
Boolean checkConsistency ? ()
SkinningAttribute clone ? ()
  cloneMembersTo ? ( io SkinningAttribute that )
  convertToCPU ! ()
  convertToGPU ! ()
  copyValue ! ( in Ref<Object> sourceAttr, in Size sourceIndex, in Size targetIndex )
  copyValue ! ( in Size sourceIndex, in Size targetIndex )
UInt16[] counts ? ()
Data data ? ()
Boolean equalValues ? ( in Size index1, in Size index2 )
UInt32 getElementsMemType ? ()
  getLinearCombination ? ( in LocalL16UInt32Array sourceIndices, in LocalL16ScalarArray sourceWeights, out LocalL16UInt32Array skinIds, out LocalL16ScalarArray skinWeights )
  getPair ? ( in UInt32 index, in UInt32 offset, out UInt16 id, out Scalar weight )
UInt16 getPairCount ? ( in UInt32 index )
  getPairs ? ( in UInt32 index, out LocalL16UInt32Array skinIds, out LocalL16ScalarArray skinWeights )
Size getScalarValueSize ? ()
UInt16[] ids ? ()
  linearCombine ! ( in Ref<Object> sourceAttr, in LocalL16UInt32Array sourceIndices, in LocalL16ScalarArray sourceWeights, in Size targetIndex )
  normalize ! ( in Size index )
UInt32[] offsets ? ()
  resize ! ( in Size count )
  setFromScalar ! ( in Size index, in LocalL16ScalarArray value )
  setPair ! ( in UInt32 index, in UInt32 offset, in UInt16 id, in Scalar weight )
  setPairCount ! ( in UInt32 index, in UInt16 pairCount )
  setPairs ! ( in UInt32 index, in LocalL16UInt32Array skinIds, in LocalL16ScalarArray skinWeights )
String truncateDecimalsPrint ? ( in Size index, in UInt32 n )
String unitTestPrint ? ( in Size index )
String valueDesc ? ( in Size index )
UInt32ArrayAllocator weightsAllocator ? ()

Methods in detail

SkinningAttribute ( in SkinningAttribute other )

copy constructor


SkinningAttribute ()

default constructor


Boolean SkinningAttribute.checkConsistency? ()

バージョン 2.4.0 で追加.

Checks the attribute data consistency.


SkinningAttribute SkinningAttribute.clone? ()

clone method


SkinningAttribute.cloneMembersTo? ( io SkinningAttribute that )


SkinningAttribute.convertToCPU! ()


SkinningAttribute.convertToGPU! ()


SkinningAttribute.copyValue! ( in Ref<Object> sourceAttr, in Size sourceIndex, in Size targetIndex )

Replaces the value located at targetIndex with source attribute’s value located at sourceIndex. The source attribute will be of the same type.


SkinningAttribute.copyValue! ( in Size sourceIndex, in Size targetIndex )

Replaces the value located at targetIndex with the value located at sourceIndex


UInt16[] SkinningAttribute.counts? ()


Data SkinningAttribute.data? ()

Returns a raw pointer to contiguous attribute data, if applicable, and an uninitialized Data otherwise.


Boolean SkinningAttribute.equalValues? ( in Size index1, in Size index2 )

Return true if two values are logically equal.


UInt32 SkinningAttribute.getElementsMemType? ()


SkinningAttribute.getLinearCombination? ( in LocalL16UInt32Array sourceIndices, in LocalL16ScalarArray sourceWeights, out LocalL16UInt32Array skinIds, out LocalL16ScalarArray skinWeights )


SkinningAttribute.getPair? ( in UInt32 index, in UInt32 offset, out UInt16 id, out Scalar weight )


UInt16 SkinningAttribute.getPairCount? ( in UInt32 index )


SkinningAttribute.getPairs? ( in UInt32 index, out LocalL16UInt32Array skinIds, out LocalL16ScalarArray skinWeights )


Size SkinningAttribute.getScalarValueSize? ()

Unsupported since we have a variable size per item


UInt16[] SkinningAttribute.ids? ()


SkinningAttribute.linearCombine! ( in Ref<Object> sourceAttr, in LocalL16UInt32Array sourceIndices, in LocalL16ScalarArray sourceWeights, in Size targetIndex )

Sets the value located at targetIndex as a linear combination of other values.

source The attribute for source values
sourceIndices The array of source indices, relatively to the source attribute.
sourceWeights The array of source weights, which need to correspond to each sourceIndices. Normally the sum of the weights should be 1.0.
targetIndex The target value index.


SkinningAttribute.normalize! ( in Size index )


UInt32[] SkinningAttribute.offsets? ()


SkinningAttribute.resize! ( in Size count )

Resizes the attribute array.


SkinningAttribute.setFromScalar! ( in Size index, in LocalL16ScalarArray value )

Unsupported since we have a variable size per item


SkinningAttribute.setPair! ( in UInt32 index, in UInt32 offset, in UInt16 id, in Scalar weight )


SkinningAttribute.setPairCount! ( in UInt32 index, in UInt16 pairCount )


SkinningAttribute.setPairs! ( in UInt32 index, in LocalL16UInt32Array skinIds, in LocalL16ScalarArray skinWeights )


String SkinningAttribute.truncateDecimalsPrint? ( in Size index, in UInt32 n )

Returns a description of the value, keeping the first n decimals (Float32 or Float64 based values).


String SkinningAttribute.unitTestPrint? ( in Size index )

Returns a numerically stable description of the value


String SkinningAttribute.valueDesc? ( in Size index )

Returns a description of the value


UInt32ArrayAllocator SkinningAttribute.weightsAllocator? ()