Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion nvse/Algohol/algMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ void V3Normalize( Vector3 &v )
v.z *= len;
}

float V3Dotproduct( Vector3 va, Vector3 vb )
{
return va.x * vb.x + va.y * vb.y + va.z * vb.z;
}

Vector3 V3Crossproduct( Vector3 va, Vector3 vb )
{
Vector3 out;
Expand Down Expand Up @@ -119,7 +124,7 @@ Quat slerp( Quat q1, Quat q2, float t )
return q1 * 0.5f + q2 * 0.5f;

float ratioA = sinf( ( 1.0f - t ) * halfTheta ) / sinHalfTheta;
float ratioB = sinf( t * halfTheta ) / sinHalfTheta;
float ratioB = sinf( t * halfTheta ) / sinHalfTheta;
return q1 * ratioA + q2 * ratioB;
}

Expand Down
2 changes: 2 additions & 0 deletions nvse/Algohol/algMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

void V3Normalize( Vector3 &v );
Vector3 V3Crossproduct( Vector3 va, Vector3 vb );
float V3Dotproduct( Vector3 va, Vector3 vb );

Quat fromEuler( Euler e, int flag );
Quat fromAxisAngle( Vector3 axis, float angle );
Quat nlerp( Quat q1, Quat q2, float t );
Quat slerp( Quat q1, Quat q2, float t );
float QDotproduct( Quat q1, Quat q2 );

Euler fromQuat( Quat q, int flag );
23 changes: 23 additions & 0 deletions nvse/Algohol/paramTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,26 @@ ParamInfo kParams_ThreeScriptVars_FourFloats_OneOptionalInt[8] =
{ "Float", kParamType_Float, 0 },
{ "flag", kParamType_Integer, 1 }
};


ParamInfo kParams_SixFloats[6] =
{
{ "Float", kParamType_Float, 0 },
{ "Float", kParamType_Float, 0 },
{ "Float", kParamType_Float, 0 },
{ "Float", kParamType_Float, 0 },
{ "Float", kParamType_Float, 0 },
{ "Float", kParamType_Float, 0 }
};

ParamInfo kParams_EightFloats[8] =
{
{ "Float", kParamType_Float, 0 },
{ "Float", kParamType_Float, 0 },
{ "Float", kParamType_Float, 0 },
{ "Float", kParamType_Float, 0 },
{ "Float", kParamType_Float, 0 },
{ "Float", kParamType_Float, 0 },
{ "Float", kParamType_Float, 0 },
{ "Float", kParamType_Float, 0 }
};
4 changes: 3 additions & 1 deletion nvse/Algohol/paramTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ extern ParamInfo kParams_FourScriptVars_FourFloats[8];
extern ParamInfo kParams_FourScriptVars_EightFloats[12];
extern ParamInfo kParams_ThreeScriptVars_SevenFloats[10];
extern ParamInfo kParams_FourScriptVars_NineFloats_OneOptionalInt[14];
extern ParamInfo kParams_ThreeScriptVars_FourFloats_OneOptionalInt[8];
extern ParamInfo kParams_ThreeScriptVars_FourFloats_OneOptionalInt[8];
extern ParamInfo kParams_SixFloats[6];
extern ParamInfo kParams_EightFloats[8];
2 changes: 2 additions & 0 deletions nvse/nvse/CommandTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2305,6 +2305,8 @@ void CommandTable::AddCommandsV6()
ADD_CMD(QInterpolateEx);
ADD_CMD(QToEulerEx);
ADD_CMD(GetUIFloatInherited);
ADD_CMD(V3DotproductEx);
ADD_CMD(QDotproductEx);
}

namespace PluginAPI
Expand Down
26 changes: 26 additions & 0 deletions nvse/nvse/commands_Algohol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ bool Cmd_V3NormalizeEx_Execute( COMMAND_ARGS )
return true;
}*/

bool Cmd_V3DotproductEx_Execute( COMMAND_ARGS )
{
*result = 0;
Vector3 v1, v2;

if (ExtractArgsEx(EXTRACT_ARGS_EX, &v1.x, &v1.y, &v1.z, &v2.x, &v2.y, &v2.z))
{
*result = V3Dotproduct( v1, v2 );
}

return true;
}

bool Cmd_V3Crossproduct_Execute( COMMAND_ARGS )
{
char vector_x_name[VBUFSIZ], vector_y_name[VBUFSIZ], vector_z_name[VBUFSIZ];
Expand Down Expand Up @@ -406,3 +419,16 @@ bool Cmd_QToEulerEx_Execute( COMMAND_ARGS )
}
return true;
}

bool Cmd_QDotproductEx_Execute( COMMAND_ARGS )
{
*result = 0;
Quat q1, q2;

if (ExtractArgsEx(EXTRACT_ARGS_EX, &q1.w, &q1.x, &q1.y, &q1.z, &q2.w, &q2.x, &q2.y, &q2.z))
{
*result = QDotproduct( q1, q2 );
}

return true;
}
2 changes: 2 additions & 0 deletions nvse/nvse/commands_Algohol.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ DEFINE_CMD_ALT(QMultQuatQuatEx, QMultQEx, Multiplies two quaternions, 0, 12, kPa
DEFINE_CMD_ALT(QMultQuatVector3Ex, QMultV3Ex, Multiplies vector3 by quaternion, 0, 10, kParams_ThreeScriptVars_SevenFloats);
DEFINE_CMD_ALT(QInterpolateEx, QIntEx, Interpolates between two quaternions, 0, 14, kParams_FourScriptVars_NineFloats_OneOptionalInt);
DEFINE_CMD_ALT(QToEulerEx, QToEEx, Converts quaternion to euler angles, 0, 8, kParams_ThreeScriptVars_FourFloats_OneOptionalInt);
DEFINE_CMD_ALT(V3DotproductEx, V3DotEx, Returns dotproduct of two vectors, 0, 6, kParams_SixFloats);
DEFINE_CMD_ALT(QDotproductEx, QDotEx, Returns dotproduct of two quaternions, 0, 8, kParams_EightFloats);
Loading