if (g_Layout_enableDetachableMenus.m_value) {
menu_tearoff(menu_in_menu);
}
- create_menu_item_with_mnemonic(menu_in_menu, "Make _Hollow", "CSGHollow");
+ create_menu_item_with_mnemonic(menu_in_menu, "Make _Hollow", "CSGMakeHollow");
+ create_menu_item_with_mnemonic(menu_in_menu, "Make _Room", "CSGMakeRoom");
create_menu_item_with_mnemonic(menu_in_menu, "CSG _Subtract", "CSGSubtract");
create_menu_item_with_mnemonic(menu_in_menu, "CSG _Merge", "CSGMerge");
}
}
}
+void Face_makeRoom(Face &face, const Brush &brush, brush_vector_t &out, float offset)
+{
+ if (face.contributes()) {
+ face.getPlane().offset(offset);
+ out.push_back(new Brush(brush));
+ face.getPlane().offset(-offset);
+ Face *newFace = out.back()->addFace(face);
+ if (newFace != 0) {
+ newFace->flipWinding();
+ newFace->planeChanged();
+ }
+ }
+}
+
void Brush_makeHollow(const Brush &brush, brush_vector_t &out, float offset)
{
Brush_forEachFace(brush, [&](Face &face) {
});
}
+void Brush_makeRoom(const Brush &brush, brush_vector_t &out, float offset)
+{
+ Brush_forEachFace(brush, [&](Face &face) {
+ Face_makeRoom(face, brush, out, offset);
+ });
+}
+
class BrushHollowSelectedWalker : public scene::Graph::Walker {
float m_offset;
+ bool m_makeRoom;
public:
- BrushHollowSelectedWalker(float offset)
- : m_offset(offset)
+ BrushHollowSelectedWalker(float offset, bool makeRoom)
+ : m_offset(offset), m_makeRoom(makeRoom)
{
}
&& Instance_getSelectable(instance)->isSelected()
&& path.size() > 1) {
brush_vector_t out;
- Brush_makeHollow(*brush, out, m_offset);
+
+ if (m_makeRoom) {
+ Brush_makeRoom(*brush, out, m_offset);
+ }
+ else {
+ Brush_makeHollow(*brush, out, m_offset);
+ }
+
for (brush_vector_t::const_iterator i = out.begin(); i != out.end(); ++i) {
(*i)->removeEmptyFaces();
NodeSmartReference node((new BrushNode())->node());
}
};
-void Scene_BrushMakeHollow_Selected(scene::Graph &graph)
+void Scene_BrushMakeHollow_Selected(scene::Graph &graph, bool makeRoom)
{
- GlobalSceneGraph().traverse(BrushHollowSelectedWalker(GetGridSize()));
+ GlobalSceneGraph().traverse(BrushHollowSelectedWalker(GetGridSize(), makeRoom));
GlobalSceneGraph().traverse(BrushDeleteSelected());
}
{
UndoableCommand undo("brushHollow");
- Scene_BrushMakeHollow_Selected(GlobalSceneGraph());
+ Scene_BrushMakeHollow_Selected(GlobalSceneGraph(), false);
+
+ SceneChangeNotify();
+}
+
+void CSG_MakeRoom(void)
+{
+ UndoableCommand undo("brushRoom");
+
+ Scene_BrushMakeHollow_Selected(GlobalSceneGraph(), true);
SceneChangeNotify();
}
{
toolbar_append_button(toolbar, "CSG Subtract (SHIFT + U)", "selection_csgsubtract.png", "CSGSubtract");
toolbar_append_button(toolbar, "CSG Merge (CTRL + U)", "selection_csgmerge.png", "CSGMerge");
- toolbar_append_button(toolbar, "Hollow", "selection_makehollow.png", "CSGHollow");
+ toolbar_append_button(toolbar, "Make Hollow", "selection_makehollow.png", "CSGMakeHollow");
+ toolbar_append_button(toolbar, "Make Room", "selection_makeroom.png", "CSGMakeRoom");
}
void ComponentModes_constructToolbar(ui::Toolbar toolbar)
GlobalCommands_insert("CSGSubtract", makeCallbackF(CSG_Subtract),
Accelerator('U', (GdkModifierType) GDK_SHIFT_MASK));
GlobalCommands_insert("CSGMerge", makeCallbackF(CSG_Merge), Accelerator('U', (GdkModifierType) GDK_CONTROL_MASK));
- GlobalCommands_insert("CSGHollow", makeCallbackF(CSG_MakeHollow));
+ GlobalCommands_insert("CSGMakeHollow", makeCallbackF(CSG_MakeHollow));
+ GlobalCommands_insert("CSGMakeRoom", makeCallbackF(CSG_MakeRoom));
Grid_registerCommands();