MCPcopy Create free account
hub / github.com/Kitware/VTK / UpdateCamera

Method UpdateCamera

Rendering/WebGPU/vtkWebGPUComputeFrustumCuller.cxx:255–285  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

253
254//------------------------------------------------------------------------------
255void vtkWebGPUComputeFrustumCuller::UpdateCamera(vtkRenderer* renderer)
256{
257 vtkCamera* camera = renderer->GetActiveCamera();
258 // Getting the view-projection matrix
259 vtkMatrix4x4* viewMatrix = camera->GetModelViewTransformMatrix();
260
261 // We're using [0, 1] for znear and zfar here to align with WebGPU convention
262 vtkMatrix4x4* projectionMatrix =
263 camera->GetProjectionTransformMatrix(renderer->GetTiledAspectRatio(), 0, 1);
264 vtkNew<vtkMatrix4x4> viewProj;
265 vtkMatrix4x4::Multiply4x4(projectionMatrix, viewMatrix, viewProj);
266 // WebGPU uses column major matrices but VTK is row major
267 viewProj->Transpose();
268
269 // Getting the matrix data as floats
270 std::vector<float> matrixData(16);
271 for (int i = 0; i < 16; i++)
272 {
273 matrixData[i] = static_cast<float>(viewProj->GetData()[i]);
274 }
275
276 // Creating / updating the view-proj matrix uniform buffer
277 if (this->CameraViewProjMatrixBufferIndex == -1)
278 {
279 this->CreateViewProjMatrixBuffer(matrixData);
280 }
281 else
282 {
283 this->FrustumCullingPass->UpdateBufferData(this->CameraViewProjMatrixBufferIndex, matrixData);
284 }
285}
286
287//------------------------------------------------------------------------------
288void vtkWebGPUComputeFrustumCuller::OutputObjectCountMapCallback(

Callers 2

CullMethod · 0.95
UpdateBuffersMethod · 0.45

Calls 8

GetActiveCameraMethod · 0.80
GetTiledAspectRatioMethod · 0.80
TransposeMethod · 0.45
GetDataMethod · 0.45
UpdateBufferDataMethod · 0.45

Tested by

no test coverage detected