| 83 | } |
| 84 | |
| 85 | void DLODNode::SelectLevelOfDetail(std::shared_ptr<Camera> const& camera) |
| 86 | { |
| 87 | // The child array of a DLODNode is compact; that is, there are no empty |
| 88 | // slots in the array and the number of children is mChild.size(). |
| 89 | // Moreover, it is assumed that all model distance values were set for |
| 90 | // these children. |
| 91 | LogAssert( |
| 92 | mChild.size() == static_cast<size_t>(mNumLevelsOfDetail), |
| 93 | "Invalid DLODNode detected by SelectLevelOfDetail."); |
| 94 | |
| 95 | for (auto const& child : mChild) |
| 96 | { |
| 97 | LogAssert( |
| 98 | child != nullptr, |
| 99 | "Invalid DLODNode child detected by SelectLevelOfDetail."); |
| 100 | } |
| 101 | |
| 102 | // Compute the world LOD center. |
| 103 | mWorldLODCenter = DoTransform(worldTransform.GetHMatrix(), mModelLODCenter); |
| 104 | |
| 105 | // Compute the world squared-distance intervals. |
| 106 | for (int32_t i = 0; i < mNumLevelsOfDetail; ++i) |
| 107 | { |
| 108 | mWorldMinDistance[i] = worldTransform.GetUniformScale() * mModelMinDistance[i]; |
| 109 | mWorldMaxDistance[i] = worldTransform.GetUniformScale() * mModelMaxDistance[i]; |
| 110 | } |
| 111 | |
| 112 | // Select the LOD child. |
| 113 | SetActiveChild(SwitchNode::invalidChild); |
| 114 | Vector4<float> diff = mWorldLODCenter - camera->GetPosition(); |
| 115 | float distance = Length(diff); |
| 116 | for (int32_t i = 0; i < mNumLevelsOfDetail; ++i) |
| 117 | { |
| 118 | if (mWorldMinDistance[i] <= distance && distance < mWorldMaxDistance[i]) |
| 119 | { |
| 120 | SetActiveChild(i); |
| 121 | break; |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | void DLODNode::GetVisibleSet(Culler& culler, std::shared_ptr<Camera> const& camera, |
| 127 | bool noCull) |
nothing calls this directly
no test coverage detected