Skip to content

Commit c778a9c

Browse files
committed
refactor
1 parent dad19db commit c778a9c

File tree

5 files changed

+10
-13
lines changed

5 files changed

+10
-13
lines changed

include/threepp/animation/AnimationClip.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace threepp {
2727

2828
void resetDuration();
2929

30-
static std::shared_ptr<AnimationClip> findByName(Object3D* object, const std::string& name);
30+
static std::shared_ptr<AnimationClip> findByName(const Object3D& object, const std::string& name);
3131
static std::shared_ptr<AnimationClip> findByName(const std::vector<std::shared_ptr<AnimationClip>>& clipArray, const std::string& name);
3232

3333
private:

include/threepp/core/Object3D.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#ifndef THREEPP_OBJECT3D_HPP
44
#define THREEPP_OBJECT3D_HPP
55

6-
#include "threepp/animation/AnimationClip.hpp"
76

87
#include "threepp/math/Euler.hpp"
98
#include "threepp/math/Matrix3.hpp"
@@ -28,6 +27,7 @@ namespace threepp {
2827
struct Intersection;
2928
class Object3D;
3029
class BufferGeometry;
30+
class AnimationClip;
3131

3232
typedef std::function<void(void*, Object3D*, Camera*, BufferGeometry*, Material*, std::optional<GeometryGroup>)> RenderCallback;
3333

src/threepp/animation/AnimationClip.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,11 @@ std::shared_ptr<AnimationClip> AnimationClip::findByName(const std::vector<std::
3939
return nullptr;
4040
}
4141

42-
std::shared_ptr<AnimationClip> AnimationClip::findByName(Object3D* object, const std::string& name) {
42+
std::shared_ptr<AnimationClip> AnimationClip::findByName(const Object3D& object, const std::string& name) {
4343

44-
std::vector<std::shared_ptr<AnimationClip>>* clipArray = nullptr;
45-
if (auto geometry = object->geometry()) {
46-
clipArray = &object->animations;
47-
}
48-
49-
if (!clipArray) return nullptr;
44+
if (!object.geometry()) return nullptr;
5045

51-
for (auto& clip : *clipArray) {
46+
for (auto& clip : object.animations) {
5247

5348
if (clip->name == name) {
5449

src/threepp/animation/AnimationMixer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ struct AnimationMixer::Impl {
126126

127127
AnimationAction* clipAction(const std::string& clipName, Object3D* optionalRoot, std::optional<AnimationBlendMode> blendMode) {
128128

129-
auto root = optionalRoot ? optionalRoot : this->_root;
130-
auto clip = AnimationClip::findByName(root, clipName);
129+
const auto root = optionalRoot ? optionalRoot : this->_root;
130+
const auto clip = AnimationClip::findByName(*root, clipName);
131131

132132
return clipAction(clip, root, blendMode);
133133
}
@@ -137,7 +137,7 @@ struct AnimationMixer::Impl {
137137
// previously unknown clip/root combination is specified)
138138
AnimationAction* clipAction(std::shared_ptr<AnimationClip> clipObject, Object3D* optionalRoot, std::optional<AnimationBlendMode> blendMode) {
139139

140-
auto root = optionalRoot ? optionalRoot : this->_root;
140+
const auto root = optionalRoot ? optionalRoot : this->_root;
141141
const auto rootUuid = root->uuid;
142142

143143
const auto clipUuid = clipObject->uuid();

src/threepp/core/Object3D.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
#include "threepp/core/Object3D.hpp"
33

4+
#include "threepp/animation/AnimationClip.hpp"
5+
46
#include "threepp/cameras/Camera.hpp"
57

68
#include "threepp/math/MathUtils.hpp"

0 commit comments

Comments
 (0)