MCPcopy Create free account
hub / github.com/BabylonJS/BabylonNative / SetMatrixN

Method SetMatrixN

Plugins/NativeEngine/Source/NativeEngine.cpp:1089–1116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1087
1088 template<int size>
1089 void NativeEngine::SetMatrixN(const Napi::CallbackInfo& info)
1090 {
1091 const auto uniformData = info[0].As<Napi::External<UniformInfo>>().Data();
1092 const auto matrix = info[1].As<Napi::Float32Array>();
1093
1094 const size_t elementLength = matrix.ElementLength();
1095 assert(elementLength == size * size);
1096
1097 if constexpr (size < 4)
1098 {
1099 std::array<float, 16> matrixValues{};
1100
1101 size_t index = 0;
1102 for (int line = 0; line < size; line++)
1103 {
1104 for (int col = 0; col < size; col++)
1105 {
1106 matrixValues[line * 4 + col] = matrix[index++];
1107 }
1108 }
1109
1110 m_currentProgram->SetUniform(uniformData->Handle, gsl::make_span(matrixValues.data(), 16));
1111 }
1112 else
1113 {
1114 m_currentProgram->SetUniform(uniformData->Handle, gsl::make_span(matrix.Data(), elementLength));
1115 }
1116 }
1117
1118 void NativeEngine::SetIntArray(const Napi::CallbackInfo& info)
1119 {

Callers

nothing calls this directly

Calls 4

assertFunction · 0.85
ElementLengthMethod · 0.80
SetUniformMethod · 0.80
DataMethod · 0.45

Tested by

no test coverage detected