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

Method update

Source/RenderPasses/SDFEditor/SelectionWheel.cpp:32–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30using namespace Falcor;
31
32void Falcor::SelectionWheel::update(const float2& mousePos, const Desc& description)
33{
34 const float kPI = (float)M_PI;
35 const float kPI2 = kPI * 2.f;
36 const float kStartOffest = kPI / 2.f;
37 mDescription = description;
38
39 const uint32_t groupCount = (uint32_t)mDescription.sectorGroups.size();
40 float minSectorAngle = FLT_MAX;
41 for (uint32_t groupIndex = 0; groupIndex < groupCount; groupIndex++)
42 {
43 float sectorAngle = getAngleOfSectorInGroup(groupIndex);
44 minSectorAngle = std::fminf(sectorAngle, minSectorAngle);
45 }
46
47 const float groupAngle = getGroupAngle();
48 float halfGroupSpacingAngle = minSectorAngle * 0.05f;
49
50 uint32_t excludeGroup = UINT32_MAX;
51
52 float dirLength;
53 float mouseAngle;
54 computeMouseAngleAndDirLength(mousePos, mouseAngle, dirLength);
55
56 float4 borderColor = mDescription.lineColor;
57 borderColor.w = mDescription.borderWidth;
58
59 // Check if mouse is hovering over the selection wheel
60 if (dirLength >= mDescription.minRadius && dirLength <= mDescription.maxRadius)
61 {
62 // Highlight the sector that the mouse is over.
63 uint32_t groupIndex, sectorIndex;
64 computeGroupAndSectorIndexFromAngle(mouseAngle, groupIndex, sectorIndex);
65 excludeGroup = groupIndex;
66
67 float rotation = getRotationOfSector(groupIndex, sectorIndex);
68 float sectorAngle = getAngleOfSectorInGroup(groupIndex);
69
70 const uint32_t kSectorCount = mDescription.sectorGroups[groupIndex];
71 uint32_t lastSectorIndex = kSectorCount - 1;
72 // If the selected sector is on the sides, render two circle sectors, one for the selected and one for the others.
73 if (sectorIndex == 0 || sectorIndex == lastSectorIndex)
74 {
75 // The other sectors.
76 float groupSpacing = sectorIndex == 0 ? halfGroupSpacingAngle : -halfGroupSpacingAngle;
77 float offset = sectorIndex == 0 ? sectorAngle : 0.0f;
78 addCircleSector(
79 groupAngle * groupIndex + offset,
80 groupAngle - sectorAngle,
81 mDescription.baseColor,
82 borderColor,
83 -groupSpacing,
84 false,
85 sectorIndex == 0 ? ExcludeBorderFlags::Left : ExcludeBorderFlags::Right
86 );
87
88 // Highlighted sector.
89 addCircleSector(rotation, sectorAngle, mDescription.highlightColor, borderColor, groupSpacing);

Callers 5

setup2DGUIMethod · 0.45
prepareLightingMethod · 0.45
executeMethod · 0.45
executeMethod · 0.45
prepareLightingMethod · 0.45

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected