AnimationValue.cpp 1.2 KB

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