[Bf-blender-cvs] [5cae2137505] master: Cleanup: pass vectors by reference
Jacques Lucke
noreply at git.blender.org
Tue Apr 12 11:56:25 CEST 2022
Commit: 5cae2137505d9e04672d47fb6067a8b5ba66812b
Author: Jacques Lucke
Date: Tue Apr 12 11:55:46 2022 +0200
Branches: master
https://developer.blender.org/rB5cae2137505d9e04672d47fb6067a8b5ba66812b
Cleanup: pass vectors by reference
Passing them by value caused measurable overhead for me.
===================================================================
M source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc
===================================================================
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;
More information about the Bf-blender-cvs
mailing list