-int GetViewAxis()
-{
- switch(GlobalXYWnd_getCurrentViewType())
- {
- case XY:
- return 2;
- case XZ:
- return 1;
- case YZ:
- return 0;
- }
- return 2;
-}
-
-void Brush_ConstructPrefab(Brush& brush, EBrushPrefab type, const AABB& bounds, std::size_t sides, const char* shader, const TextureProjection& projection)
-{
- switch(type)
- {
- case eBrushCuboid:
- {
- UndoableCommand undo("brushCuboid");
-
- Brush_ConstructCuboid(brush, bounds, shader, projection);
- }
- break;
- case eBrushPrism:
- {
- int axis = GetViewAxis();
- StringOutputStream command;
- command << c_brushPrism_name << " -sides " << Unsigned(sides) << " -axis " << axis;
- UndoableCommand undo(command.c_str());
-
- Brush_ConstructPrism(brush, bounds, sides, axis, shader, projection);
- }
- break;
- case eBrushCone:
- {
- StringOutputStream command;
- command << c_brushCone_name << " -sides " << Unsigned(sides);
- UndoableCommand undo(command.c_str());
-
- Brush_ConstructCone(brush, bounds, sides, shader, projection);
- }
- break;
- case eBrushSphere:
- {
- StringOutputStream command;
- command << c_brushSphere_name << " -sides " << Unsigned(sides);
- UndoableCommand undo(command.c_str());
-
- Brush_ConstructSphere(brush, bounds, sides, shader, projection);
- }
- break;
- case eBrushRock:
- {
- StringOutputStream command;
- command << c_brushRock_name << " -sides " << Unsigned(sides);
- UndoableCommand undo(command.c_str());
-
- Brush_ConstructRock(brush, bounds, sides, shader, projection);
- }
- break;
- }
-}
-
-
-void ConstructRegionBrushes(scene::Node* brushes[6], const Vector3& region_mins, const Vector3& region_maxs)
-{
- {
- // set mins
- Vector3 mins(region_mins[0]-32, region_mins[1]-32, region_mins[2]-32);
-
- // vary maxs
- for(std::size_t i=0; i<3; i++)
- {
- Vector3 maxs(region_maxs[0]+32, region_maxs[1]+32, region_maxs[2]+32);
- maxs[i] = region_mins[i];
- Brush_ConstructCuboid(*Node_getBrush(*brushes[i]), aabb_for_minmax(mins, maxs), texdef_name_default(), TextureProjection());
- }
- }
-
- {
- // set maxs
- Vector3 maxs(region_maxs[0]+32, region_maxs[1]+32, region_maxs[2]+32);
-
- // vary mins
- for(std::size_t i=0; i<3; i++)
- {
- Vector3 mins(region_mins[0]-32, region_mins[1]-32, region_mins[2]-32);
- mins[i] = region_maxs[i];
- Brush_ConstructCuboid(*Node_getBrush(*brushes[i+3]), aabb_for_minmax(mins, maxs), texdef_name_default(), TextureProjection());
- }
- }
-}
-
-
-class FaceSetTexdef
-{
- const TextureProjection& m_projection;
-public:
- FaceSetTexdef(const TextureProjection& projection) : m_projection(projection)
- {
- }
- void operator()(Face& face) const
- {
- face.SetTexdef(m_projection);
- }
-};
-
-void Scene_BrushSetTexdef_Selected(scene::Graph& graph, const TextureProjection& projection)
-{
- Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetTexdef(projection));
- SceneChangeNotify();