AnimationValue.cpp 1.1 KB

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