Cleanup: pass vectors by reference
Passing them by value caused measurable overhead for me.
This commit is contained in:
parent
b4a2096415
commit
5cae213750
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue