AnimationValue.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. GP_ASSERT(_componentCount > 0);
  9. _value = new float[_componentCount];
  10. }
  11. AnimationValue::~AnimationValue()
  12. {
  13. SAFE_DELETE_ARRAY(_value);
  14. }
  15. float AnimationValue::getFloat(unsigned int index) const
  16. {
  17. GP_ASSERT(index < _componentCount);
  18. GP_ASSERT(_value);
  19. return _value[index];
  20. }
  21. void AnimationValue::setFloat(unsigned int index, float value)
  22. {
  23. GP_ASSERT(index < _componentCount);
  24. GP_ASSERT(_value);
  25. _value[index] = value;
  26. }
  27. void AnimationValue::getFloat(float* value, unsigned int offset, unsigned int length) const
  28. {
  29. GP_ASSERT(_value && value && offset < _componentCount && (offset + length) <= _componentCount);
  30. memcpy(value + offset, _value, length * sizeof(float));
  31. }
  32. void AnimationValue::setFloat(float* value, unsigned int offset, unsigned int length)
  33. {
  34. GP_ASSERT(_value && value && offset < _componentCount && (offset + length) <= _componentCount);
  35. memcpy(_value, value + offset, length * sizeof(float));
  36. }
  37. }