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

Method SetTypeArrayN

Plugins/NativeEngine/Source/NativeEngine.cpp:1052–1072  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1050
1051 template<int size, typename arrayType>
1052 void NativeEngine::SetTypeArrayN(const Napi::CallbackInfo& info)
1053 {
1054 const auto uniformData = info[0].As<Napi::External<UniformInfo>>().Data();
1055 const auto array = info[1].As<arrayType>();
1056
1057 size_t elementLength = array.ElementLength();
1058
1059 m_scratch.clear();
1060 for (size_t index = 0; index < elementLength; index += size)
1061 {
1062 const float values[] = {
1063 static_cast<float>(array[index]),
1064 (size > 1) ? static_cast<float>(array[index + 1]) : 0.f,
1065 (size > 2) ? static_cast<float>(array[index + 2]) : 0.f,
1066 (size > 3) ? static_cast<float>(array[index + 3]) : 0.f,
1067 };
1068 m_scratch.insert(m_scratch.end(), values, values + 4);
1069 }
1070
1071 m_currentProgram->SetUniform(uniformData->Handle, m_scratch, elementLength / size);
1072 }
1073
1074 template<int size>
1075 void NativeEngine::SetFloatN(const Napi::CallbackInfo& info)

Callers

nothing calls this directly

Calls 3

ElementLengthMethod · 0.80
SetUniformMethod · 0.80
DataMethod · 0.45

Tested by

no test coverage detected