diff options
author | Jacques Lucke <jacques@blender.org> | 2022-04-12 12:55:46 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-04-12 12:56:02 +0300 |
commit | 5cae2137505d9e04672d47fb6067a8b5ba66812b (patch) | |
tree | 2fc90652ef09ee09fadf3546b1aede9ab6efcde6 /source/blender/nodes | |
parent | b4a2096415d97c68182f47f07962f2809bab4578 (diff) |
Cleanup: pass vectors by reference
Passing them by value caused measurable overhead for me.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc index a041492fb13..b35f686e331 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc @@ -69,9 +69,9 @@ static int gpu_shader_vector_rotate(GPUMaterial *mat, return 0; } -static float3 sh_node_vector_rotate_around_axis(const float3 vector, - const float3 center, - const float3 axis, +static float3 sh_node_vector_rotate_around_axis(const float3 &vector, + const float3 ¢er, + const float3 &axis, const float angle) { float3 result = vector - center; @@ -81,9 +81,9 @@ static float3 sh_node_vector_rotate_around_axis(const float3 vector, return result + center; } -static float3 sh_node_vector_rotate_euler(const float3 vector, - const float3 center, - const float3 rotation, +static float3 sh_node_vector_rotate_euler(const float3 &vector, + const float3 ¢er, + const float3 &rotation, const bool invert) { float mat[3][3]; @@ -105,13 +105,15 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_VECTOR_ROTATE_TYPE_AXIS: { if (invert) { static fn::CustomMF_SI_SI_SI_SI_SO<float3, float3, float3, float, float3> fn{ - "Rotate Axis", [](float3 in, float3 center, float3 axis, float angle) { + "Rotate Axis", + [](const float3 &in, const float3 ¢er, const float3 &axis, float angle) { return sh_node_vector_rotate_around_axis(in, center, axis, -angle); }}; return &fn; } static fn::CustomMF_SI_SI_SI_SI_SO<float3, float3, float3, float, float3> fn{ - "Rotate Axis", [](float3 in, float3 center, float3 axis, float angle) { + "Rotate Axis", + [](const float3 &in, const float3 ¢er, const float3 &axis, float angle) { return sh_node_vector_rotate_around_axis(in, center, axis, angle); }}; return &fn; @@ -120,13 +122,13 @@ static const fn::MultiFunction *get_multi_function(bNode &node) float3 axis = float3(1.0f, 0.0f, 0.0f); if (invert) { static fn::CustomMF_SI_SI_SI_SO<float3, float3, float, float3> fn{ - "Rotate X-Axis", [=](float3 in, float3 center, float angle) { + "Rotate X-Axis", [=](const float3 &in, const float3 ¢er, float angle) { return sh_node_vector_rotate_around_axis(in, center, axis, -angle); }}; return &fn; } static fn::CustomMF_SI_SI_SI_SO<float3, float3, float, float3> fn{ - "Rotate X-Axis", [=](float3 in, float3 center, float angle) { + "Rotate X-Axis", [=](const float3 &in, const float3 ¢er, float angle) { return sh_node_vector_rotate_around_axis(in, center, axis, angle); }}; return &fn; @@ -135,13 +137,13 @@ static const fn::MultiFunction *get_multi_function(bNode &node) float3 axis = float3(0.0f, 1.0f, 0.0f); if (invert) { static fn::CustomMF_SI_SI_SI_SO<float3, float3, float, float3> fn{ - "Rotate Y-Axis", [=](float3 in, float3 center, float angle) { + "Rotate Y-Axis", [=](const float3 &in, const float3 ¢er, float angle) { return sh_node_vector_rotate_around_axis(in, center, axis, -angle); }}; return &fn; } static fn::CustomMF_SI_SI_SI_SO<float3, float3, float, float3> fn{ - "Rotate Y-Axis", [=](float3 in, float3 center, float angle) { + "Rotate Y-Axis", [=](const float3 &in, const float3 ¢er, float angle) { return sh_node_vector_rotate_around_axis(in, center, axis, angle); }}; return &fn; @@ -150,13 +152,13 @@ static const fn::MultiFunction *get_multi_function(bNode &node) float3 axis = float3(0.0f, 0.0f, 1.0f); if (invert) { static fn::CustomMF_SI_SI_SI_SO<float3, float3, float, float3> fn{ - "Rotate Z-Axis", [=](float3 in, float3 center, float angle) { + "Rotate Z-Axis", [=](const float3 &in, const float3 ¢er, float angle) { return sh_node_vector_rotate_around_axis(in, center, axis, -angle); }}; return &fn; } static fn::CustomMF_SI_SI_SI_SO<float3, float3, float, float3> fn{ - "Rotate Z-Axis", [=](float3 in, float3 center, float angle) { + "Rotate Z-Axis", [=](const float3 &in, const float3 ¢er, float angle) { return sh_node_vector_rotate_around_axis(in, center, axis, angle); }}; return &fn; @@ -164,13 +166,13 @@ static const fn::MultiFunction *get_multi_function(bNode &node) case NODE_VECTOR_ROTATE_TYPE_EULER_XYZ: { if (invert) { static fn::CustomMF_SI_SI_SI_SO<float3, float3, float3, float3> fn{ - "Rotate Euler", [](float3 in, float3 center, float3 rotation) { + "Rotate Euler", [](const float3 &in, const float3 ¢er, const float3 &rotation) { return sh_node_vector_rotate_euler(in, center, rotation, true); }}; return &fn; } static fn::CustomMF_SI_SI_SI_SO<float3, float3, float3, float3> fn{ - "Rotate Euler", [](float3 in, float3 center, float3 rotation) { + "Rotate Euler", [](const float3 &in, const float3 ¢er, const float3 &rotation) { return sh_node_vector_rotate_euler(in, center, rotation, false); }}; return &fn; |