| 1064 | } |
| 1065 | |
| 1066 | void BindlessDeferred::UpdateDecals(const Timer& timer) |
| 1067 | { |
| 1068 | if(AppSettings::ClearDecals.Pressed()) |
| 1069 | numDecals = 0; |
| 1070 | |
| 1071 | // Update picking and placing new decals |
| 1072 | cursorDecal = Decal(); |
| 1073 | cursorDecal.Type = uint32(-1); |
| 1074 | cursorDecalIntensity = 0.0f; |
| 1075 | if(currMouseState.IsOverWindow && AppSettings::EnableDecalPicker) |
| 1076 | { |
| 1077 | // Update the decal cursor |
| 1078 | const uint64 texIdx = currDecalType * AppSettings::NumTexturesPerDecal; |
| 1079 | Assert_(texIdx < ArraySize_(decalTextures)); |
| 1080 | |
| 1081 | Float2 textureSize; |
| 1082 | textureSize.x = float(decalTextures[texIdx].Width); |
| 1083 | textureSize.y = float(decalTextures[texIdx].Height); |
| 1084 | const float sizeScale = 1 / 1024.0f; |
| 1085 | |
| 1086 | const PickingData* pickingData = pickingReadbackBuffers[DX12::CurrFrameIdx].Map<PickingData>(); |
| 1087 | if(pickingData->Normal != Float3(0.0f, 0.0f, 0.0f)) |
| 1088 | { |
| 1089 | const float decalThickness = 0.125f; |
| 1090 | |
| 1091 | cursorDecal.Position = pickingData->Position; |
| 1092 | cursorDecal.Size = Float3(textureSize.x * sizeScale, textureSize.y * sizeScale, decalThickness); |
| 1093 | cursorDecal.Type = uint32(currDecalType); |
| 1094 | cursorDecalIntensity = float(std::cos(timer.ElapsedSecondsD() * Pi2)) * 0.25f + 0.5f; |
| 1095 | |
| 1096 | Float3 forward = -pickingData->Normal; |
| 1097 | Float3 up = std::abs(Float3::Dot(forward, Float3(0.0f, 1.0f, 0.0f))) < 0.99f ? Float3(0.0f, 1.0f, 0.0f) : Float3(0.0f, 0.0f, 1.0f); |
| 1098 | Float3 right = Float3::Normalize(Float3::Cross(up, forward)); |
| 1099 | up = Float3::Cross(forward, right); |
| 1100 | Float3x3 orientation = Float3x3(right, up, forward); |
| 1101 | |
| 1102 | cursorDecal.Orientation = Quaternion(orientation); |
| 1103 | |
| 1104 | if(currMouseState.MButton.RisingEdge) |
| 1105 | { |
| 1106 | // Place a new decal, and fill the buffer |
| 1107 | const uint64 decalIdx = (numDecals++) % AppSettings::MaxDecals; |
| 1108 | decals[decalIdx] = cursorDecal; |
| 1109 | |
| 1110 | currDecalType = (currDecalType + 1) % uint64(AppSettings::NumDecalTypes); |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | pickingReadbackBuffers[DX12::CurrFrameIdx].Unmap(); |
| 1115 | } |
| 1116 | |
| 1117 | // Update the Z bounds, and fill the buffers |
| 1118 | const Float4x4 viewMatrix = camera.ViewMatrix(); |
| 1119 | const float nearClip = camera.NearClip(); |
| 1120 | const float farClip = camera.FarClip(); |
| 1121 | const float zRange = farClip - nearClip; |
| 1122 | const Float3 cameraPos = camera.Position(); |
| 1123 | const float3 boxVerts[8] = { float3(-1, 1, -1), float3(1, 1, -1), float3(-1, 1, 1), float3(1, 1, 1), |
nothing calls this directly
no test coverage detected