AnimationValue.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "Base.h"
  2. #include "AnimationValue.h"
  3. namespace gameplay
  4. {
  5. AnimationValue::AnimationValue(unsigned int componentCount)
  6. : _componentCount(componentCount), _componentSize(componentCount * sizeof(float))
  7. {
  8. _value = new float[_componentCount];
  9. }
  10. AnimationValue::~AnimationValue()
  11. {
  12. SAFE_DELETE_ARRAY(_value);
  13. }
  14. float AnimationValue::getFloat(unsigned int index) const
  15. {
  16. assert(index < _componentCount);
  17. return _value[index];
  18. }
  19. void AnimationValue::setFloat(unsigned int index, float value)
  20. {
  21. assert(index < _componentCount);
  22. _value[index] = value;
  23. }
  24. void AnimationValue::getFloat(float* value, unsigned int offset, unsigned int length) const
  25. {
  26. assert(value && offset < _componentCount && (offset + length) <= _componentCount);
  27. memcpy(value + offset, _value, length * sizeof(float));
  28. }
  29. void AnimationValue::setFloat(float* value, unsigned int offset, unsigned int length)
  30. {
  31. assert(value && offset < _componentCount && (offset + length) <= _componentCount);
  32. memcpy(_value, value + offset, length * sizeof(float));
  33. }
  34. }