MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / manipulateGridPlane

Method manipulateGridPlane

Source/RenderPasses/SDFEditor/SDFEditor.cpp:389–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

387}
388
389void SDFEditor::manipulateGridPlane(
390 SDFGridPlane& gridPlane,
391 SDFGridPlane& previousGridPlane,
392 bool isTranslationKeyDown,
393 bool isConstrainedManipulationKeyDown
394)
395{
396 float2 diffPrev = mUI2D.currentMousePosition - mUI2D.prevMousePosition;
397 float2 diffStart = mUI2D.currentMousePosition - mUI2D.startMousePosition;
398 float3 up = mpCamera->getUpVector();
399 float3 view = normalize(mpCamera->getTarget() - mpCamera->getPosition());
400 float3 right = cross(view, up);
401
402 if (!isTranslationKeyDown) // The user wants rotation of the grid plane.
403 {
404 if (!isConstrainedManipulationKeyDown) // Rotate plane arbitrarily along right and up vectors.
405 {
406 // Rotate plane around the right vector.
407 rotateGridPlane(
408 diffPrev.y, right, previousGridPlane.normal, previousGridPlane.rightVector, gridPlane.normal, gridPlane.rightVector
409 );
410 // Rotate plane around the up vector.
411 rotateGridPlane(diffPrev.x, up, gridPlane.normal, gridPlane.rightVector, gridPlane.normal, gridPlane.rightVector);
412 previousGridPlane = gridPlane;
413 }
414 else // Constraind rotation to the axis with most movement since shift was pressed.
415 {
416 if (std::abs(diffStart.y) > std::abs(diffStart.x)) // Rotate plane only around the right vector.
417 {
418 rotateGridPlane(
419 diffStart.y,
420 right,
421 previousGridPlane.normal,
422 previousGridPlane.rightVector,
423 gridPlane.normal,
424 gridPlane.rightVector,
425 false
426 );
427 }
428 else // Rotate plane only around the up vector.
429 {
430 rotateGridPlane(
431 diffStart.x, up, previousGridPlane.normal, previousGridPlane.rightVector, gridPlane.normal, gridPlane.rightVector, false
432 );
433 }
434 }
435 }
436 else // The user wants translation of the grid plane.
437 {
438 if (!isConstrainedManipulationKeyDown)
439 {
440 translateGridPlane(diffPrev.x, right, previousGridPlane.position, gridPlane.position);
441 translateGridPlane(-diffPrev.y, up, gridPlane.position, gridPlane.position);
442 previousGridPlane = gridPlane;
443 }
444 else
445 {
446 if (std::abs(diffStart.y) > std::abs(diffStart.x)) // Translate plane only along the right vector.

Callers

nothing calls this directly

Calls 5

getUpVectorMethod · 0.80
normalizeFunction · 0.50
crossFunction · 0.50
absFunction · 0.50
getPositionMethod · 0.45

Tested by

no test coverage detected