| 152 | } |
| 153 | |
| 154 | Mesh* Combine(Actor* actor, MeshesLookup& cache, Mesh* combineParent) |
| 155 | { |
| 156 | ASSERT(actor); |
| 157 | Mesh* result = nullptr; |
| 158 | Mesh* myBrush = nullptr; |
| 159 | cache.TryGet(actor, myBrush); |
| 160 | |
| 161 | // Get first child mesh with valid data (has additive brush) |
| 162 | int32 childIndex = 0; |
| 163 | while (childIndex < actor->Children.Count()) |
| 164 | { |
| 165 | auto child = Combine(actor->Children[childIndex], cache, combineParent); |
| 166 | |
| 167 | childIndex++; |
| 168 | if (child) |
| 169 | { |
| 170 | // If brush was based on additive brush or current actor is a brush we can stop searching |
| 171 | if (child->HasMode(Mode::Additive) || myBrush) |
| 172 | { |
| 173 | // End searching |
| 174 | result = child; |
| 175 | break; |
| 176 | } |
| 177 | |
| 178 | if (combineParent) |
| 179 | { |
| 180 | // Combine |
| 181 | combineParent->PerformOperation(child); |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | // Check if has any child with CSG brush |
| 187 | if (result) |
| 188 | { |
| 189 | // Check if has own brush |
| 190 | if (myBrush) |
| 191 | { |
| 192 | // Combine with first child |
| 193 | myBrush->PerformOperation(result); |
| 194 | |
| 195 | // Set this actor brush as a result |
| 196 | result = myBrush; |
| 197 | } |
| 198 | |
| 199 | // Merge with the other children |
| 200 | while (childIndex < actor->Children.Count()) |
| 201 | { |
| 202 | auto child = Combine(actor->Children[childIndex], cache, result); |
| 203 | if (child) |
| 204 | { |
| 205 | // Combine |
| 206 | result->PerformOperation(child); |
| 207 | } |
| 208 | |
| 209 | childIndex++; |
| 210 | } |
| 211 | } |
no test coverage detected