| 121 | typedef Dictionary<Actor*, Mesh*> MeshesLookup; |
| 122 | |
| 123 | bool walkTree(Actor* actor, MeshesArray& meshes, MeshesLookup& cache) |
| 124 | { |
| 125 | // Check if actor is a brush |
| 126 | auto brush = dynamic_cast<Brush*>(actor); |
| 127 | if (brush) |
| 128 | { |
| 129 | // Check if can build it |
| 130 | if (brush->CanUseCSG()) |
| 131 | { |
| 132 | // Skip subtract/common meshes from the beginning (they have no effect) |
| 133 | if (meshes.Count() > 0 || brush->GetBrushMode() == Mode::Additive) |
| 134 | { |
| 135 | // Create new mesh and build for given brush |
| 136 | auto mesh = New<CSG::Mesh>(); |
| 137 | mesh->Build(brush); |
| 138 | |
| 139 | // Save results |
| 140 | meshes.Add(mesh); |
| 141 | cache.Add(actor, mesh); |
| 142 | } |
| 143 | else |
| 144 | { |
| 145 | // Info |
| 146 | LOG(Info, "Skipping CSG brush '{0}'", actor->ToString()); |
| 147 | } |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | return true; |
| 152 | } |
| 153 | |
| 154 | Mesh* Combine(Actor* actor, MeshesLookup& cache, Mesh* combineParent) |
| 155 | { |