2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "brushmanip.h"
25 #include "gtkutil/widget.h"
26 #include "gtkutil/menu.h"
28 #include "brushnode.h"
30 #include "texwindow.h"
33 #include "mainframe.h"
36 #include "preferences.h"
41 void Brush_ConstructCuboid(Brush& brush, const AABB& bounds, const char* shader, const TextureProjection& projection)
43 const unsigned char box[3][2] = { { 0, 1 }, { 2, 0 }, { 1, 2 } };
44 Vector3 mins(vector3_subtracted(bounds.origin, bounds.extents));
45 Vector3 maxs(vector3_added(bounds.origin, bounds.extents));
52 for(int i=0; i < 3; ++i)
54 Vector3 planepts1(maxs);
55 Vector3 planepts2(maxs);
56 planepts2[box[i][0]] = mins[box[i][0]];
57 planepts1[box[i][1]] = mins[box[i][1]];
59 brush.addPlane(maxs, planepts1, planepts2, shader, projection);
63 for(int i=0; i < 3; ++i)
65 Vector3 planepts1(mins);
66 Vector3 planepts2(mins);
67 planepts1[box[i][0]] = maxs[box[i][0]];
68 planepts2[box[i][1]] = maxs[box[i][1]];
70 brush.addPlane(mins, planepts1, planepts2, shader, projection);
75 inline float max_extent(const Vector3& extents)
77 return std::max(std::max(extents[0], extents[1]), extents[2]);
80 inline float max_extent_2d(const Vector3& extents, int axis)
85 return std::max(extents[1], extents[2]);
87 return std::max(extents[0], extents[2]);
89 return std::max(extents[0], extents[1]);
93 const std::size_t c_brushPrism_minSides = 3;
94 const std::size_t c_brushPrism_maxSides = c_brush_maxFaces - 2;
95 const char* const c_brushPrism_name = "brushPrism";
97 void Brush_ConstructPrism(Brush& brush, const AABB& bounds, std::size_t sides, int axis, const char* shader, const TextureProjection& projection)
99 if(sides < c_brushPrism_minSides)
101 globalErrorStream() << c_brushPrism_name << ": sides " << Unsigned(sides) << ": too few sides, minimum is " << Unsigned(c_brushPrism_minSides) << "\n";
104 if(sides > c_brushPrism_maxSides)
106 globalErrorStream() << c_brushPrism_name << ": sides " << Unsigned(sides) << ": too many sides, maximum is " << Unsigned(c_brushPrism_maxSides) << "\n";
112 brush.reserve(sides+2);
114 Vector3 mins(vector3_subtracted(bounds.origin, bounds.extents));
115 Vector3 maxs(vector3_added(bounds.origin, bounds.extents));
117 float radius = max_extent_2d(bounds.extents, axis);
118 const Vector3& mid = bounds.origin;
121 planepts[2][(axis+1)%3] = mins[(axis+1)%3];
122 planepts[2][(axis+2)%3] = mins[(axis+2)%3];
123 planepts[2][axis] = maxs[axis];
124 planepts[1][(axis+1)%3] = maxs[(axis+1)%3];
125 planepts[1][(axis+2)%3] = mins[(axis+2)%3];
126 planepts[1][axis] = maxs[axis];
127 planepts[0][(axis+1)%3] = maxs[(axis+1)%3];
128 planepts[0][(axis+2)%3] = maxs[(axis+2)%3];
129 planepts[0][axis] = maxs[axis];
131 brush.addPlane(planepts[0], planepts[1], planepts[2], shader, projection);
133 planepts[0][(axis+1)%3] = mins[(axis+1)%3];
134 planepts[0][(axis+2)%3] = mins[(axis+2)%3];
135 planepts[0][axis] = mins[axis];
136 planepts[1][(axis+1)%3] = maxs[(axis+1)%3];
137 planepts[1][(axis+2)%3] = mins[(axis+2)%3];
138 planepts[1][axis] = mins[axis];
139 planepts[2][(axis+1)%3] = maxs[(axis+1)%3];
140 planepts[2][(axis+2)%3] = maxs[(axis+2)%3];
141 planepts[2][axis] = mins[axis];
143 brush.addPlane(planepts[0], planepts[1], planepts[2], shader, projection);
145 for (std::size_t i=0 ; i<sides ; ++i)
147 double sv = sin (i*3.14159265*2/sides);
148 double cv = cos (i*3.14159265*2/sides);
150 planepts[0][(axis+1)%3] = static_cast<float>(floor(mid[(axis+1)%3]+radius*cv+0.5));
151 planepts[0][(axis+2)%3] = static_cast<float>(floor(mid[(axis+2)%3]+radius*sv+0.5));
152 planepts[0][axis] = mins[axis];
154 planepts[1][(axis+1)%3] = planepts[0][(axis+1)%3];
155 planepts[1][(axis+2)%3] = planepts[0][(axis+2)%3];
156 planepts[1][axis] = maxs[axis];
158 planepts[2][(axis+1)%3] = static_cast<float>(floor(planepts[0][(axis+1)%3] - radius*sv + 0.5));
159 planepts[2][(axis+2)%3] = static_cast<float>(floor(planepts[0][(axis+2)%3] + radius*cv + 0.5));
160 planepts[2][axis] = maxs[axis];
162 brush.addPlane(planepts[0], planepts[1], planepts[2], shader, projection);
166 const std::size_t c_brushCone_minSides = 3;
167 const std::size_t c_brushCone_maxSides = 32;
168 const char* const c_brushCone_name = "brushCone";
170 void Brush_ConstructCone(Brush& brush, const AABB& bounds, std::size_t sides, const char* shader, const TextureProjection& projection)
172 if(sides < c_brushCone_minSides)
174 globalErrorStream() << c_brushCone_name << ": sides " << Unsigned(sides) << ": too few sides, minimum is " << Unsigned(c_brushCone_minSides) << "\n";
177 if(sides > c_brushCone_maxSides)
179 globalErrorStream() << c_brushCone_name << ": sides " << Unsigned(sides) << ": too many sides, maximum is " << Unsigned(c_brushCone_maxSides) << "\n";
185 brush.reserve(sides+1);
187 Vector3 mins(vector3_subtracted(bounds.origin, bounds.extents));
188 Vector3 maxs(vector3_added(bounds.origin, bounds.extents));
190 float radius = max_extent(bounds.extents);
191 const Vector3& mid = bounds.origin;
194 planepts[0][0] = mins[0];planepts[0][1] = mins[1];planepts[0][2] = mins[2];
195 planepts[1][0] = maxs[0];planepts[1][1] = mins[1];planepts[1][2] = mins[2];
196 planepts[2][0] = maxs[0];planepts[2][1] = maxs[1];planepts[2][2] = mins[2];
198 brush.addPlane(planepts[0], planepts[1], planepts[2], shader, projection);
200 for (std::size_t i=0 ; i<sides ; ++i)
202 double sv = sin (i*3.14159265*2/sides);
203 double cv = cos (i*3.14159265*2/sides);
205 planepts[0][0] = static_cast<float>(floor(mid[0]+radius*cv+0.5));
206 planepts[0][1] = static_cast<float>(floor(mid[1]+radius*sv+0.5));
207 planepts[0][2] = mins[2];
209 planepts[1][0] = mid[0];
210 planepts[1][1] = mid[1];
211 planepts[1][2] = maxs[2];
213 planepts[2][0] = static_cast<float>(floor(planepts[0][0] - radius * sv + 0.5));
214 planepts[2][1] = static_cast<float>(floor(planepts[0][1] + radius * cv + 0.5));
215 planepts[2][2] = maxs[2];
217 brush.addPlane(planepts[0], planepts[1], planepts[2], shader, projection);
221 const std::size_t c_brushSphere_minSides = 3;
222 const std::size_t c_brushSphere_maxSides = 7;
223 const char* const c_brushSphere_name = "brushSphere";
225 void Brush_ConstructSphere(Brush& brush, const AABB& bounds, std::size_t sides, const char* shader, const TextureProjection& projection)
227 if(sides < c_brushSphere_minSides)
229 globalErrorStream() << c_brushSphere_name << ": sides " << Unsigned(sides) << ": too few sides, minimum is " << Unsigned(c_brushSphere_minSides) << "\n";
232 if(sides > c_brushSphere_maxSides)
234 globalErrorStream() << c_brushSphere_name << ": sides " << Unsigned(sides) << ": too many sides, maximum is " << Unsigned(c_brushSphere_maxSides) << "\n";
240 brush.reserve(sides*sides);
242 float radius = max_extent(bounds.extents);
243 const Vector3& mid = bounds.origin;
246 double dt = 2 * c_pi / sides;
247 double dp = c_pi / sides;
248 for(std::size_t i=0; i < sides; i++)
250 for(std::size_t j=0;j < sides-1; j++)
253 double p = float(j * dp - c_pi / 2);
255 planepts[0] = vector3_added(mid, vector3_scaled(vector3_for_spherical(t, p), radius));
256 planepts[1] = vector3_added(mid, vector3_scaled(vector3_for_spherical(t, p + dp), radius));
257 planepts[2] = vector3_added(mid, vector3_scaled(vector3_for_spherical(t + dt, p + dp), radius));
259 brush.addPlane(planepts[0], planepts[1], planepts[2], shader, projection);
264 double p = (sides - 1) * dp - c_pi / 2;
265 for(std::size_t i = 0; i < sides; i++)
269 planepts[0] = vector3_added(mid, vector3_scaled(vector3_for_spherical(t, p), radius));
270 planepts[1] = vector3_added(mid, vector3_scaled(vector3_for_spherical(t + dt, p + dp), radius));
271 planepts[2] = vector3_added(mid, vector3_scaled(vector3_for_spherical(t + dt, p), radius));
273 brush.addPlane(planepts[0], planepts[1], planepts[2], shader, projection);
280 switch(GlobalXYWnd_getCurrentViewType())
292 void Brush_ConstructPrefab(Brush& brush, EBrushPrefab type, const AABB& bounds, std::size_t sides, const char* shader, const TextureProjection& projection)
298 UndoableCommand undo("brushCuboid");
300 Brush_ConstructCuboid(brush, bounds, shader, projection);
305 int axis = GetViewAxis();
306 StringOutputStream command;
307 command << c_brushPrism_name << " -sides " << Unsigned(sides) << " -axis " << axis;
308 UndoableCommand undo(command.c_str());
310 Brush_ConstructPrism(brush, bounds, sides, axis, shader, projection);
315 StringOutputStream command;
316 command << c_brushCone_name << " -sides " << Unsigned(sides);
317 UndoableCommand undo(command.c_str());
319 Brush_ConstructCone(brush, bounds, sides, shader, projection);
324 StringOutputStream command;
325 command << c_brushSphere_name << " -sides " << Unsigned(sides);
326 UndoableCommand undo(command.c_str());
328 Brush_ConstructSphere(brush, bounds, sides, shader, projection);
335 void ConstructRegionBrushes(scene::Node* brushes[6], const Vector3& region_mins, const Vector3& region_maxs)
339 Vector3 mins(region_mins[0]-32, region_mins[1]-32, region_mins[2]-32);
342 for(std::size_t i=0; i<3; i++)
344 Vector3 maxs(region_maxs[0]+32, region_maxs[1]+32, region_maxs[2]+32);
345 maxs[i] = region_mins[i];
346 Brush_ConstructCuboid(*Node_getBrush(*brushes[i]), aabb_for_minmax(mins, maxs), texdef_name_default(), TextureProjection());
352 Vector3 maxs(region_maxs[0]+32, region_maxs[1]+32, region_maxs[2]+32);
355 for(std::size_t i=0; i<3; i++)
357 Vector3 mins(region_mins[0]-32, region_mins[1]-32, region_mins[2]-32);
358 mins[i] = region_maxs[i];
359 Brush_ConstructCuboid(*Node_getBrush(*brushes[i+3]), aabb_for_minmax(mins, maxs), texdef_name_default(), TextureProjection());
365 class BrushForEachFace
367 const BrushInstanceVisitor& m_visitor;
369 BrushForEachFace(const BrushInstanceVisitor& visitor) : m_visitor(visitor)
372 void operator()(BrushInstance& brush) const
374 brush.forEachFaceInstance(m_visitor);
378 template<class Visitor>
379 class FaceVisitAll : public BrushInstanceVisitor
381 const Visitor& m_visitor;
383 FaceVisitAll(const Visitor& visitor)
387 void visit(FaceInstance& face) const
389 m_visitor.visit(face.getFace());
393 template<class Visitor>
394 class FaceInstanceVisitAll : public BrushInstanceVisitor
396 const Visitor& m_visitor;
398 FaceInstanceVisitAll(const Visitor& visitor)
402 void visit(FaceInstance& face) const
404 m_visitor.visit(face);
408 template<class Visitor>
409 class FaceVisitSelected : public BrushInstanceVisitor
411 const Visitor& m_visitor;
413 FaceVisitSelected(const Visitor& visitor)
417 void visit(FaceInstance& face) const
419 if(face.isSelected(SelectionSystem::eFace))
421 m_visitor.visit(face.getFace());
426 template<typename Functor>
427 inline void Scene_forEachBrush(scene::Graph& graph, const Functor& functor)
429 graph.traverse(InstanceWalker< InstanceApply<BrushInstance, Functor> >(functor));
432 template<typename Type, typename Functor>
433 class InstanceIfVisible : public Functor
436 InstanceIfVisible(const Functor& functor) : Functor(functor)
439 void operator()(scene::Instance& instance)
441 if(instance.path().top().get().visible())
443 Functor::operator()(instance);
448 template<typename Functor>
449 class BrushVisibleWalker : public scene::Graph::Walker
451 const Functor& m_functor;
453 BrushVisibleWalker(const Functor& functor) : m_functor(functor)
456 bool pre(const scene::Path& path, scene::Instance& instance) const
458 if(path.top().get().visible())
460 BrushInstance* brush = Instance_getBrush(instance);
470 template<typename Functor>
471 inline void Scene_forEachVisibleBrush(scene::Graph& graph, const Functor& functor)
473 graph.traverse(BrushVisibleWalker<Functor>(functor));
476 template<typename Visitor>
477 inline void Scene_ForEachBrush_ForEachFace(scene::Graph& graph, const Visitor& visitor)
479 Scene_forEachBrush(graph, BrushForEachFace(FaceVisitAll<Visitor>(visitor)));
482 template<typename Visitor>
483 inline void Scene_ForEachSelectedBrush_ForEachFace(scene::Graph& graph, const Visitor& visitor)
485 Scene_forEachSelectedBrush(BrushForEachFace(FaceVisitAll<Visitor>(visitor)));
488 template<typename Visitor>
489 inline void Scene_ForEachSelectedBrush_ForEachFaceInstance(scene::Graph& graph, const Visitor& visitor)
491 Scene_forEachSelectedBrush(BrushForEachFace(FaceInstanceVisitAll<Visitor>(visitor)));
494 template<typename Visitor>
495 class FaceVisitorWrapper
499 FaceVisitorWrapper(Visitor& visitor) : m_visitor(visitor)
503 void operator()(FaceInstance& faceInstance)
505 m_visitor.visit(faceInstance.getFace());
509 template<typename Visitor>
510 inline void Scene_ForEachSelectedBrushFace(scene::Graph& graph, Visitor& faceVisitor)
512 g_SelectedFaceInstances.foreach(FaceVisitorWrapper<Visitor>(faceVisitor));
517 class FaceSetTexdefVisitor
519 const TextureProjection& m_projection;
521 FaceSetTexdefVisitor(const TextureProjection& projection) : m_projection(projection)
524 void visit(Face& face) const
526 face.SetTexdef(m_projection);
530 void Scene_BrushSetTexdef_Selected(scene::Graph& graph, const TextureProjection& projection)
532 Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetTexdefVisitor(projection));
536 void Scene_BrushSetTexdef_Component_Selected(scene::Graph& graph, const TextureProjection& projection)
538 FaceSetTexdefVisitor visitor(projection);
539 Scene_ForEachSelectedBrushFace(graph, visitor);
544 class FaceSetFlagsVisitor
546 const ContentsFlagsValue& m_projection;
548 FaceSetFlagsVisitor(const ContentsFlagsValue& flags) : m_projection(flags)
551 void visit(Face& face) const
553 face.SetFlags(m_projection);
557 void Scene_BrushSetFlags_Selected(scene::Graph& graph, const ContentsFlagsValue& flags)
559 Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetFlagsVisitor(flags));
563 void Scene_BrushSetFlags_Component_Selected(scene::Graph& graph, const ContentsFlagsValue& flags)
565 FaceSetFlagsVisitor visitor(flags);
566 Scene_ForEachSelectedBrushFace(graph, visitor);
570 class FaceShiftTexdefVisitor
574 FaceShiftTexdefVisitor(float s, float t) : m_s(s), m_t(t)
577 void visit(Face& face) const
579 face.ShiftTexdef(m_s, m_t);
583 void Scene_BrushShiftTexdef_Selected(scene::Graph& graph, float s, float t)
585 Scene_ForEachSelectedBrush_ForEachFace(graph, FaceShiftTexdefVisitor(s, t));
589 void Scene_BrushShiftTexdef_Component_Selected(scene::Graph& graph, float s, float t)
591 FaceShiftTexdefVisitor visitor(s, t);
592 Scene_ForEachSelectedBrushFace(graph, visitor);
596 class FaceScaleTexdefVisitor
600 FaceScaleTexdefVisitor(float s, float t) : m_s(s), m_t(t)
603 void visit(Face& face) const
605 face.ScaleTexdef(m_s, m_t);
609 void Scene_BrushScaleTexdef_Selected(scene::Graph& graph, float s, float t)
611 Scene_ForEachSelectedBrush_ForEachFace(graph, FaceScaleTexdefVisitor(s, t));
615 void Scene_BrushScaleTexdef_Component_Selected(scene::Graph& graph, float s, float t)
617 FaceScaleTexdefVisitor visitor(s, t);
618 Scene_ForEachSelectedBrushFace(graph, visitor);
622 class FaceRotateTexdefVisitor
626 FaceRotateTexdefVisitor(float angle) : m_angle(angle)
629 void visit(Face& face) const
631 face.RotateTexdef(m_angle);
635 void Scene_BrushRotateTexdef_Selected(scene::Graph& graph, float angle)
637 Scene_ForEachSelectedBrush_ForEachFace(graph, FaceRotateTexdefVisitor(angle));
641 void Scene_BrushRotateTexdef_Component_Selected(scene::Graph& graph, float angle)
643 FaceRotateTexdefVisitor visitor(angle);
644 Scene_ForEachSelectedBrushFace(graph, visitor);
649 class FaceSetShaderVisitor
653 FaceSetShaderVisitor(const char* name) : m_name(name) {}
654 void visit(Face& face) const
656 face.SetShader(m_name);
660 void Scene_BrushSetShader_Selected(scene::Graph& graph, const char* name)
662 Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetShaderVisitor(name));
666 void Scene_BrushSetShader_Component_Selected(scene::Graph& graph, const char* name)
668 FaceSetShaderVisitor visitor(name);
669 Scene_ForEachSelectedBrushFace(graph, visitor);
673 class FaceSetDetailVisitor
677 FaceSetDetailVisitor(bool detail) : m_detail(detail)
680 void visit(Face& face) const
682 face.setDetail(m_detail);
686 void Scene_BrushSetDetail_Selected(scene::Graph& graph, bool detail)
688 Scene_ForEachSelectedBrush_ForEachFace(graph, FaceSetDetailVisitor(detail));
692 bool Face_FindReplaceShader(Face& face, const char* find, const char* replace)
694 if(shader_equal(face.GetShader(), find))
696 face.SetShader(replace);
702 class FaceFindReplaceShaderVisitor
705 const char* m_replace;
707 FaceFindReplaceShaderVisitor(const char* find, const char* replace) : m_find(find), m_replace(replace)
710 void visit(Face& face) const
712 Face_FindReplaceShader(face, m_find, m_replace);
716 void Scene_BrushFindReplaceShader(scene::Graph& graph, const char* find, const char* replace)
718 Scene_ForEachBrush_ForEachFace(graph, FaceFindReplaceShaderVisitor(find, replace));
721 void Scene_BrushFindReplaceShader_Selected(scene::Graph& graph, const char* find, const char* replace)
723 Scene_ForEachSelectedBrush_ForEachFace(graph, FaceFindReplaceShaderVisitor(find, replace));
726 void Scene_BrushFindReplaceShader_Component_Selected(scene::Graph& graph, const char* find, const char* replace)
728 FaceFindReplaceShaderVisitor visitor(find, replace);
729 Scene_ForEachSelectedBrushFace(graph, visitor);
733 class FaceFitTextureVisitor
735 float m_s_repeat, m_t_repeat;
737 FaceFitTextureVisitor(float s_repeat, float t_repeat) : m_s_repeat(s_repeat), m_t_repeat(t_repeat)
740 void visit(Face& face) const
742 face.FitTexture(m_s_repeat, m_t_repeat);
746 void Scene_BrushFitTexture_Selected(scene::Graph& graph, float s_repeat, float t_repeat)
748 Scene_ForEachSelectedBrush_ForEachFace(graph, FaceFitTextureVisitor(s_repeat, t_repeat));
752 void Scene_BrushFitTexture_Component_Selected(scene::Graph& graph, float s_repeat, float t_repeat)
754 FaceFitTextureVisitor visitor(s_repeat, t_repeat);
755 Scene_ForEachSelectedBrushFace(graph, visitor);
760 void Scene_BrushConstructPrefab(scene::Graph& graph, EBrushPrefab type, std::size_t sides, const char* shader)
762 if(GlobalSelectionSystem().countSelected() != 0)
764 const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
766 Brush* brush = Node_getBrush(path.top());
769 AABB bounds = brush->localAABB();
770 TextureProjection projection;
771 TexDef_Construct_Default(projection);
772 Brush_ConstructPrefab(*brush, type, bounds, sides, shader, projection);
778 void Scene_BrushResize_Selected(scene::Graph& graph, const AABB& bounds, const char* shader)
780 if(GlobalSelectionSystem().countSelected() != 0)
782 const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
784 Brush* brush = Node_getBrush(path.top());
787 TextureProjection projection;
788 TexDef_Construct_Default(projection);
789 Brush_ConstructCuboid(*brush, bounds, shader, projection);
795 bool Brush_hasShader(const Brush& brush, const char* name)
797 for(Brush::const_iterator i = brush.begin(); i != brush.end(); ++i)
799 if(shader_equal((*i)->GetShader(), name))
807 class BrushSelectByShaderWalker : public scene::Graph::Walker
811 BrushSelectByShaderWalker(const char* name)
815 bool pre(const scene::Path& path, scene::Instance& instance) const
817 if(path.top().get().visible())
819 Brush* brush = Node_getBrush(path.top());
820 if(brush != 0 && Brush_hasShader(*brush, m_name))
822 Instance_getSelectable(instance)->setSelected(true);
829 void Scene_BrushSelectByShader(scene::Graph& graph, const char* name)
831 graph.traverse(BrushSelectByShaderWalker(name));
834 class FaceSelectByShaderVisitor : public BrushInstanceVisitor
838 FaceSelectByShaderVisitor(const char* name)
842 void visit(FaceInstance& face) const
844 if(shader_equal(face.getFace().GetShader(), m_name))
846 face.setSelected(SelectionSystem::eFace, true);
851 void Scene_BrushSelectByShader_Component(scene::Graph& graph, const char* name)
853 Scene_ForEachSelectedBrush_ForEachFaceInstance(graph, FaceSelectByShaderVisitor(name));
856 class FaceGetTexdefVisitor
858 TextureProjection& m_projection;
861 FaceGetTexdefVisitor(TextureProjection& projection)
862 : m_projection(projection), m_done(false)
865 void visit(Face& face) const
870 FaceTexdef_getTexdef(face.getTexdef(), m_projection);
876 void Scene_BrushGetTexdef_Selected(scene::Graph& graph, TextureProjection& projection)
878 FaceGetTexdefVisitor visitor(projection);
879 Scene_ForEachSelectedBrush_ForEachFace(graph, visitor);
882 void Scene_BrushGetTexdef_Component_Selected(scene::Graph& graph, TextureProjection& projection)
885 if(!g_SelectedFaceInstances.empty())
887 FaceInstance& faceInstance = g_SelectedFaceInstances.last();
888 FaceTexdef_getTexdef(faceInstance.getFace().getTexdef(), projection);
891 FaceGetTexdefVisitor visitor(projection);
892 Scene_ForEachSelectedBrushFace(graph, visitor);
897 class FaceGetFlagsVisitor
899 ContentsFlagsValue& m_flags;
902 FaceGetFlagsVisitor(ContentsFlagsValue& flags)
903 : m_flags(flags), m_done(false)
906 void visit(Face& face) const
911 FaceShader_getFlags(face.getShader(), m_flags);
917 void Scene_BrushGetFlags_Selected(scene::Graph& graph, ContentsFlagsValue& flags)
919 FaceGetFlagsVisitor visitor(flags);
920 Scene_ForEachSelectedBrush_ForEachFace(graph, visitor);
923 void Scene_BrushGetFlags_Component_Selected(scene::Graph& graph, ContentsFlagsValue& flags)
926 if(!g_SelectedFaceInstances.empty())
928 FaceInstance& faceInstance = g_SelectedFaceInstances.last();
929 FaceShader_getFlags(faceInstance.getFace().getShader(), flags);
932 FaceGetFlagsVisitor visitor(flags);
933 Scene_ForEachSelectedBrushFace(graph, visitor);
938 class FaceGetShaderVisitor
940 CopiedString& m_shader;
943 FaceGetShaderVisitor(CopiedString& shader)
944 : m_shader(shader), m_done(false)
947 void visit(Face& face) const
952 m_shader = face.getShader().getShader();
957 void Scene_BrushGetShader_Selected(scene::Graph& graph, CopiedString& shader)
959 FaceGetShaderVisitor visitor(shader);
960 Scene_ForEachSelectedBrush_ForEachFace(graph, visitor);
963 void Scene_BrushGetShader_Component_Selected(scene::Graph& graph, CopiedString& shader)
966 if(!g_SelectedFaceInstances.empty())
968 FaceInstance& faceInstance = g_SelectedFaceInstances.last();
969 shader = faceInstance.getFace().getShader().getShader();
972 FaceGetShaderVisitor visitor(shader);
973 Scene_ForEachSelectedBrushFace(graph, visitor);
978 class filter_face_shader : public FaceFilter
980 const char* m_shader;
982 filter_face_shader(const char* shader) : m_shader(shader)
985 bool filter(const Face& face) const
987 return shader_equal(face.GetShader(), m_shader);
991 class filter_face_shader_substring : public FaceFilter
993 const char* m_shader;
995 filter_face_shader_substring(const char* shader) : m_shader(shader)
998 bool filter(const Face& face) const
1000 return shader_equal_n(face.GetShader(), m_shader, strlen(m_shader));
1004 class filter_face_flags : public FaceFilter
1008 filter_face_flags(int flags) : m_flags(flags)
1011 bool filter(const Face& face) const
1013 return (face.getShader().shaderFlags() & m_flags) != 0;
1017 class filter_face_contents : public FaceFilter
1021 filter_face_contents(int contents) : m_contents(contents)
1024 bool filter(const Face& face) const
1026 return (face.getShader().m_flags.m_contentFlags & m_contents) != 0;
1032 class FaceFilterAnyVisitor : public BrushVisitor
1034 FaceFilter* m_filter;
1037 FaceFilterAnyVisitor(FaceFilter* filter, bool& filtered) : m_filter(filter), m_filtered(filtered)
1041 void visit(Face& face) const
1043 if(m_filter->filter(face))
1050 class filter_brush_any_face : public BrushFilter
1052 FaceFilter* m_filter;
1054 filter_brush_any_face(FaceFilter* filter) : m_filter(filter)
1057 bool filter(const Brush& brush) const
1060 brush.forEachFace(FaceFilterAnyVisitor(m_filter, filtered));
1065 class FaceFilterAllVisitor : public BrushVisitor
1067 FaceFilter* m_filter;
1070 FaceFilterAllVisitor(FaceFilter* filter, bool& filtered) : m_filter(filter), m_filtered(filtered)
1074 void visit(Face& face) const
1076 if(!m_filter->filter(face))
1083 class filter_brush_all_faces : public BrushFilter
1085 FaceFilter* m_filter;
1087 filter_brush_all_faces(FaceFilter* filter) : m_filter(filter)
1090 bool filter(const Brush& brush) const
1093 brush.forEachFace(FaceFilterAllVisitor(m_filter, filtered));
1099 filter_face_flags g_filter_face_clip(QER_CLIP);
1100 filter_brush_all_faces g_filter_brush_clip(&g_filter_face_clip);
1102 filter_face_shader g_filter_face_clip_q2("textures/clip");
1103 filter_brush_all_faces g_filter_brush_clip_q2(&g_filter_face_clip_q2);
1105 filter_face_shader g_filter_face_weapclip("textures/common/weapclip");
1106 filter_brush_all_faces g_filter_brush_weapclip(&g_filter_face_weapclip);
1108 filter_face_shader g_filter_face_botclip("textures/common/botclip");
1109 filter_brush_all_faces g_filter_brush_botclip(&g_filter_face_botclip);
1111 filter_face_shader g_filter_face_caulk("textures/common/caulk");
1112 filter_brush_all_faces g_filter_brush_caulk(&g_filter_face_caulk);
1114 filter_face_shader g_filter_face_caulk_ja("textures/system/caulk");
1115 filter_brush_all_faces g_filter_brush_caulk_ja(&g_filter_face_caulk_ja);
1117 filter_face_shader_substring g_filter_face_liquids("textures/liquids/");
1118 filter_brush_any_face g_filter_brush_liquids(&g_filter_face_liquids);
1120 filter_face_shader g_filter_face_hint("textures/common/hint");
1121 filter_brush_any_face g_filter_brush_hint(&g_filter_face_hint);
1123 filter_face_shader g_filter_face_hint_q2("textures/hint");
1124 filter_brush_any_face g_filter_brush_hint_q2(&g_filter_face_hint_q2);
1126 filter_face_shader g_filter_face_hint_ja("textures/system/hint");
1127 filter_brush_any_face g_filter_brush_hint_ja(&g_filter_face_hint_ja);
1129 filter_face_shader g_filter_face_areaportal("textures/common/areaportal");
1130 filter_brush_all_faces g_filter_brush_areaportal(&g_filter_face_areaportal);
1132 filter_face_shader g_filter_face_visportal("textures/editor/visportal");
1133 filter_brush_any_face g_filter_brush_visportal(&g_filter_face_visportal);
1135 filter_face_shader g_filter_face_clusterportal("textures/common/clusterportal");
1136 filter_brush_all_faces g_filter_brush_clusterportal(&g_filter_face_clusterportal);
1138 filter_face_shader g_filter_face_lightgrid("textures/common/lightgrid");
1139 filter_brush_all_faces g_filter_brush_lightgrid(&g_filter_face_lightgrid);
1141 filter_face_flags g_filter_face_translucent(QER_TRANS);
1142 filter_brush_all_faces g_filter_brush_translucent(&g_filter_face_translucent);
1144 filter_face_contents g_filter_face_detail(CONTENTS_DETAIL);
1145 filter_brush_all_faces g_filter_brush_detail(&g_filter_face_detail);
1148 void BrushFilters_construct()
1150 add_brush_filter(g_filter_brush_clip, EXCLUDE_CLIP);
1151 add_brush_filter(g_filter_brush_clip_q2, EXCLUDE_CLIP);
1152 add_brush_filter(g_filter_brush_weapclip, EXCLUDE_CLIP);
1153 add_brush_filter(g_filter_brush_botclip, EXCLUDE_BOTCLIP);
1154 add_brush_filter(g_filter_brush_caulk, EXCLUDE_CAULK);
1155 add_brush_filter(g_filter_brush_caulk_ja, EXCLUDE_CAULK);
1156 add_brush_filter(g_filter_brush_liquids, EXCLUDE_LIQUIDS);
1157 add_brush_filter(g_filter_brush_hint, EXCLUDE_HINTSSKIPS);
1158 add_brush_filter(g_filter_brush_hint_q2, EXCLUDE_HINTSSKIPS);
1159 add_brush_filter(g_filter_brush_hint_ja, EXCLUDE_HINTSSKIPS);
1160 add_brush_filter(g_filter_brush_clusterportal, EXCLUDE_CLUSTERPORTALS);
1161 add_brush_filter(g_filter_brush_visportal, EXCLUDE_VISPORTALS);
1162 add_brush_filter(g_filter_brush_areaportal, EXCLUDE_AREAPORTALS);
1163 add_brush_filter(g_filter_brush_translucent, EXCLUDE_TRANSLUCENT);
1164 add_brush_filter(g_filter_brush_detail, EXCLUDE_DETAILS);
1165 add_brush_filter(g_filter_brush_detail, EXCLUDE_STRUCTURAL, true);
1166 add_brush_filter(g_filter_brush_lightgrid, EXCLUDE_LIGHTGRID);
1171 void normalquantisation_draw()
1175 for(std::size_t i = 0; i <= c_quantise_normal; ++i)
1177 for(std::size_t j = 0; j <= c_quantise_normal; ++j)
1179 Normal3f vertex(normal3f_normalised(Normal3f(
1180 static_cast<float>(c_quantise_normal - j - i),
1181 static_cast<float>(i),
1182 static_cast<float>(j)
1184 VectorScale(normal3f_to_array(vertex), 64.f, normal3f_to_array(vertex));
1185 glVertex3fv(normal3f_to_array(vertex));
1186 vertex.x = -vertex.x;
1187 glVertex3fv(normal3f_to_array(vertex));
1193 class RenderableNormalQuantisation : public OpenGLRenderable
1196 void render(RenderStateFlags state) const
1198 normalquantisation_draw();
1202 const float g_test_quantise_normal = 1.f / static_cast<float>(1 << 3);
1204 class TestNormalQuantisation
1206 void check_normal(const Normal3f& normal, const Normal3f& other)
1208 spherical_t spherical = spherical_from_normal3f(normal);
1209 double longditude = RAD2DEG(spherical.longditude);
1210 double latitude = RAD2DEG(spherical.latitude);
1211 double x = cos(spherical.longditude) * sin(spherical.latitude);
1212 double y = sin(spherical.longditude) * sin(spherical.latitude);
1213 double z = cos(spherical.latitude);
1215 ASSERT_MESSAGE(normal3f_dot(normal, other) > 0.99, "bleh");
1218 void test_normal(const Normal3f& normal)
1220 Normal3f test = normal3f_from_spherical(spherical_from_normal3f(normal));
1221 check_normal(normal, test);
1223 EOctant octant = normal3f_classify_octant(normal);
1224 Normal3f folded = normal3f_fold_octant(normal, octant);
1225 ESextant sextant = normal3f_classify_sextant(folded);
1226 folded = normal3f_fold_sextant(folded, sextant);
1228 double scale = static_cast<float>(c_quantise_normal) / (folded.x + folded.y + folded.z);
1230 double zbits = folded.z * scale;
1231 double ybits = folded.y * scale;
1233 std::size_t zbits_q = static_cast<std::size_t>(zbits);
1234 std::size_t ybits_q = static_cast<std::size_t>(ybits);
1236 ASSERT_MESSAGE(zbits_q <= (c_quantise_normal / 8) * 3, "bleh");
1237 ASSERT_MESSAGE(ybits_q <= (c_quantise_normal / 2), "bleh");
1238 ASSERT_MESSAGE(zbits_q + ((c_quantise_normal / 2) - ybits_q) <= (c_quantise_normal / 2), "bleh");
1240 std::size_t y_t = (zbits_q < (c_quantise_normal / 4)) ? ybits_q : (c_quantise_normal / 2) - ybits_q;
1241 std::size_t z_t = (zbits_q < (c_quantise_normal / 4)) ? zbits_q : (c_quantise_normal / 2) - zbits_q;
1242 std::size_t index = (c_quantise_normal / 4) * y_t + z_t;
1243 ASSERT_MESSAGE(index <= (c_quantise_normal / 4)*(c_quantise_normal / 2), "bleh");
1245 Normal3f tmp(c_quantise_normal - zbits_q - ybits_q, ybits_q, zbits_q);
1246 tmp = normal3f_normalised(tmp);
1248 Normal3f unfolded = normal3f_unfold_octant(normal3f_unfold_sextant(tmp, sextant), octant);
1250 check_normal(normal, unfolded);
1252 double dot = normal3f_dot(normal, unfolded);
1253 float length = VectorLength(normal3f_to_array(unfolded));
1254 float inv_length = 1 / length;
1256 Normal3f quantised = normal3f_quantised(normal);
1257 check_normal(normal, quantised);
1259 void test2(const Normal3f& normal, const Normal3f& other)
1261 if(normal3f_quantised(normal) != normal3f_quantised(other))
1267 static Normal3f normalise(float x, float y, float z)
1269 return normal3f_normalised(Normal3f(x, y, z));
1274 return static_cast<float>(rand() - (RAND_MAX/2));
1277 Normal3f normal3f_rand()
1279 return normalise(vec_rand(), vec_rand(), vec_rand());
1283 TestNormalQuantisation()
1285 for(int i = 4096; i > 0; --i)
1286 test_normal(normal3f_rand());
1288 test_normal(normalise(1, 0, 0));
1289 test_normal(normalise(0, 1, 0));
1290 test_normal(normalise(0, 0, 1));
1291 test_normal(normalise(1, 1, 0));
1292 test_normal(normalise(1, 0, 1));
1293 test_normal(normalise(0, 1, 1));
1295 test_normal(normalise(10000, 10000, 10000));
1296 test_normal(normalise(10000, 10000, 10001));
1297 test_normal(normalise(10000, 10000, 10002));
1298 test_normal(normalise(10000, 10000, 10010));
1299 test_normal(normalise(10000, 10000, 10020));
1300 test_normal(normalise(10000, 10000, 10030));
1301 test_normal(normalise(10000, 10000, 10100));
1302 test_normal(normalise(10000, 10000, 10101));
1303 test_normal(normalise(10000, 10000, 10102));
1304 test_normal(normalise(10000, 10000, 10200));
1305 test_normal(normalise(10000, 10000, 10201));
1306 test_normal(normalise(10000, 10000, 10202));
1307 test_normal(normalise(10000, 10000, 10203));
1308 test_normal(normalise(10000, 10000, 10300));
1311 test2(normalise(10000, 10000, 10000), normalise(10000, 10000, 10001));
1312 test2(normalise(10000, 10000, 10001), normalise(10000, 10001, 10000));
1316 TestNormalQuantisation g_testNormalQuantisation;
1322 class TestSelectableObserver : public observer_template<const Selectable&>
1325 void notify(const Selectable& arguments)
1327 bool bleh = arguments.isSelected();
1331 inline void test_bleh()
1333 TestSelectableObserver test;
1334 ObservableSelectableInstance< SingleObservable< SelectionChangeCallback > > bleh;
1336 bleh.setSelected(true);
1349 const TestBleh testbleh;
1354 class TestRefcountedString
1357 TestRefcountedString()
1361 SmartString string1("string1");
1362 SmartString string2(string1);
1363 SmartString string3(string2);
1366 // refcounted assignment
1367 SmartString string1("string1");
1368 SmartString string2("string2");
1373 SmartString string1("string1");
1374 SmartString string2("string2");
1375 string1 = string2.c_str();
1379 SmartString string1("string1");
1383 // self-assignment via another reference
1384 SmartString string1("string1");
1385 SmartString string2(string1);
1391 const TestRefcountedString g_testRefcountedString;
1395 void Select_MakeDetail()
1397 UndoableCommand undo("brushSetDetail");
1398 Scene_BrushSetDetail_Selected(GlobalSceneGraph(), true);
1401 void Select_MakeStructural()
1403 UndoableCommand undo("brushClearDetail");
1404 Scene_BrushSetDetail_Selected(GlobalSceneGraph(), false);
1407 class BrushMakeSided
1409 std::size_t m_count;
1411 BrushMakeSided(std::size_t count)
1417 Scene_BrushConstructPrefab(GlobalSceneGraph(), eBrushPrism, m_count, TextureBrowser_GetSelectedShader(GlobalTextureBrowser()));
1419 typedef MemberCaller<BrushMakeSided, &BrushMakeSided::set> SetCaller;
1423 BrushMakeSided g_brushmakesided3(3);
1424 BrushMakeSided g_brushmakesided4(4);
1425 BrushMakeSided g_brushmakesided5(5);
1426 BrushMakeSided g_brushmakesided6(6);
1427 BrushMakeSided g_brushmakesided7(7);
1428 BrushMakeSided g_brushmakesided8(8);
1429 BrushMakeSided g_brushmakesided9(9);
1431 inline int axis_for_viewtype(int viewtype)
1447 EBrushPrefab m_type;
1449 BrushPrefab(EBrushPrefab type)
1455 DoSides(m_type, axis_for_viewtype(GetViewAxis()));
1457 typedef MemberCaller<BrushPrefab, &BrushPrefab::set> SetCaller;
1460 BrushPrefab g_brushprism(eBrushPrism);
1461 BrushPrefab g_brushcone(eBrushCone);
1462 BrushPrefab g_brushsphere(eBrushSphere);
1468 void OnClipMode(bool enable);
1476 UndoableCommand undo("clipperClip");
1481 void SplitSelected()
1485 UndoableCommand undo("clipperSplit");
1496 Callback g_texture_lock_status_changed;
1497 BoolExportCaller g_texdef_movelock_caller(g_brush_texturelock_enabled);
1498 ToggleItem g_texdef_movelock_item(g_texdef_movelock_caller);
1500 void Texdef_ToggleMoveLock()
1502 g_brush_texturelock_enabled = !g_brush_texturelock_enabled;
1503 g_texdef_movelock_item.update();
1504 g_texture_lock_status_changed();
1510 void Face_getClosest(Face& face, SelectionTest& test, SelectionIntersection& bestIntersection, Face*& closestFace)
1512 SelectionIntersection intersection;
1513 face.testSelect(test, intersection);
1514 if(intersection.valid()
1515 && SelectionIntersection_closer(intersection, bestIntersection))
1517 bestIntersection = intersection;
1518 closestFace = &face;
1523 class OccludeSelector : public Selector
1525 SelectionIntersection& m_bestIntersection;
1528 OccludeSelector(SelectionIntersection& bestIntersection, bool& occluded) : m_bestIntersection(bestIntersection), m_occluded(occluded)
1532 void pushSelectable(Selectable& selectable)
1535 void popSelectable()
1538 void addIntersection(const SelectionIntersection& intersection)
1540 if(SelectionIntersection_closer(intersection, m_bestIntersection))
1542 m_bestIntersection = intersection;
1548 class BrushGetClosestFaceVisibleWalker : public scene::Graph::Walker
1550 SelectionTest& m_test;
1551 Face*& m_closestFace;
1552 mutable SelectionIntersection m_bestIntersection;
1554 BrushGetClosestFaceVisibleWalker(SelectionTest& test, Face*& closestFace) : m_test(test), m_closestFace(closestFace)
1557 bool pre(const scene::Path& path, scene::Instance& instance) const
1559 if(path.top().get().visible())
1561 BrushInstance* brush = Instance_getBrush(instance);
1564 m_test.BeginMesh(brush->localToWorld());
1566 for(Brush::const_iterator i = brush->getBrush().begin(); i != brush->getBrush().end(); ++i)
1568 Face_getClosest(*(*i), m_test, m_bestIntersection, m_closestFace);
1573 SelectionTestable* selectionTestable = Instance_getSelectionTestable(instance);
1574 if(selectionTestable)
1577 OccludeSelector selector(m_bestIntersection, occluded);
1578 selectionTestable->testSelect(selector, m_test);
1590 Face* Scene_BrushGetClosestFace(scene::Graph& graph, SelectionTest& test)
1592 Face* closestFace = 0;
1593 graph.traverse(BrushGetClosestFaceVisibleWalker(test, closestFace));
1597 bool Scene_BrushGetClosestFaceTexture(scene::Graph& graph, SelectionTest& test, CopiedString& shader, TextureProjection& projection, ContentsFlagsValue& flags)
1599 Face* face = Scene_BrushGetClosestFace(graph, test);
1602 shader = face->GetShader();
1603 FaceTexdef_getTexdef(face->getTexdef(), projection);
1604 flags = face->getShader().m_flags;
1610 void Scene_BrushSetClosestFaceTexture(scene::Graph& graph, SelectionTest& test, const char* shader, const TextureProjection& projection, const ContentsFlagsValue& flags)
1612 Face* face = Scene_BrushGetClosestFace(graph, test);
1615 face->SetShader(shader);
1616 face->SetTexdef(projection);
1617 face->SetFlags(flags);
1625 TextureProjection m_projection;
1626 ContentsFlagsValue m_flags;
1629 FaceTexture g_faceTextureClipboard;
1631 void FaceTextureClipboard_setDefault()
1633 g_faceTextureClipboard.m_flags = ContentsFlagsValue(0, 0, 0, false);
1634 TexDef_Construct_Default(g_faceTextureClipboard.m_projection);
1637 void TextureClipboard_textureSelected(const char* shader)
1639 FaceTextureClipboard_setDefault();
1642 class TextureBrowser;
1643 extern TextureBrowser g_TextureBrowser;
1644 void TextureBrowser_SetSelectedShader(TextureBrowser& textureBrowser, const char* shader);
1645 const char* TextureBrowser_GetSelectedShader(TextureBrowser& textureBrowser);
1647 void Scene_copyClosestFaceTexture(SelectionTest& test)
1649 CopiedString shader;
1650 if(Scene_BrushGetClosestFaceTexture(GlobalSceneGraph(), test, shader, g_faceTextureClipboard.m_projection, g_faceTextureClipboard.m_flags))
1652 TextureBrowser_SetSelectedShader(g_TextureBrowser, shader.c_str());
1656 void Scene_applyClosestFaceTexture(SelectionTest& test)
1658 UndoableCommand command("facePaintTexture");
1660 Scene_BrushSetClosestFaceTexture(GlobalSceneGraph(), test, TextureBrowser_GetSelectedShader(g_TextureBrowser), g_faceTextureClipboard.m_projection, g_faceTextureClipboard.m_flags);
1662 SceneChangeNotify();
1667 void SelectedFaces_copyTexture()
1669 if(!g_SelectedFaceInstances.empty())
1671 Face& face = g_SelectedFaceInstances.last().getFace();
1672 FaceTexdef_getTexdef(face.getTexdef(), g_faceTextureClipboard.m_projection);
1673 g_faceTextureClipboard.m_flags = face.getShader().m_flags;
1675 TextureBrowser_SetSelectedShader(g_TextureBrowser, face.getShader().getShader());
1679 void FaceInstance_pasteTexture(FaceInstance& faceInstance)
1681 faceInstance.getFace().SetTexdef(g_faceTextureClipboard.m_projection);
1682 faceInstance.getFace().SetShader(TextureBrowser_GetSelectedShader(g_TextureBrowser));
1683 faceInstance.getFace().SetFlags(g_faceTextureClipboard.m_flags);
1684 SceneChangeNotify();
1687 void SelectedFaces_pasteTexture()
1689 UndoableCommand command("facePasteTexture");
1690 g_SelectedFaceInstances.foreach(FaceInstance_pasteTexture);
1693 void Brush_registerCommands()
1695 GlobalToggles_insert("TogTexLock", FreeCaller<Texdef_ToggleMoveLock>(), ToggleItem::AddCallbackCaller(g_texdef_movelock_item), Accelerator('T', (GdkModifierType)GDK_SHIFT_MASK));
1697 GlobalCommands_insert("BrushPrism", BrushPrefab::SetCaller(g_brushprism));
1698 GlobalCommands_insert("BrushCone", BrushPrefab::SetCaller(g_brushcone));
1699 GlobalCommands_insert("BrushSphere", BrushPrefab::SetCaller(g_brushsphere));
1701 GlobalCommands_insert("Brush3Sided", BrushMakeSided::SetCaller(g_brushmakesided3), Accelerator('3', (GdkModifierType)GDK_CONTROL_MASK));
1702 GlobalCommands_insert("Brush4Sided", BrushMakeSided::SetCaller(g_brushmakesided4), Accelerator('4', (GdkModifierType)GDK_CONTROL_MASK));
1703 GlobalCommands_insert("Brush5Sided", BrushMakeSided::SetCaller(g_brushmakesided5), Accelerator('5', (GdkModifierType)GDK_CONTROL_MASK));
1704 GlobalCommands_insert("Brush6Sided", BrushMakeSided::SetCaller(g_brushmakesided6), Accelerator('6', (GdkModifierType)GDK_CONTROL_MASK));
1705 GlobalCommands_insert("Brush7Sided", BrushMakeSided::SetCaller(g_brushmakesided7), Accelerator('7', (GdkModifierType)GDK_CONTROL_MASK));
1706 GlobalCommands_insert("Brush8Sided", BrushMakeSided::SetCaller(g_brushmakesided8), Accelerator('8', (GdkModifierType)GDK_CONTROL_MASK));
1707 GlobalCommands_insert("Brush9Sided", BrushMakeSided::SetCaller(g_brushmakesided9), Accelerator('9', (GdkModifierType)GDK_CONTROL_MASK));
1709 GlobalCommands_insert("ClipSelected", FreeCaller<ClipSelected>(), Accelerator(GDK_Return));
1710 GlobalCommands_insert("SplitSelected", FreeCaller<SplitSelected>(), Accelerator(GDK_Return, (GdkModifierType)GDK_SHIFT_MASK));
1711 GlobalCommands_insert("FlipClip", FreeCaller<FlipClipper>(), Accelerator(GDK_Return, (GdkModifierType)GDK_CONTROL_MASK));
1713 GlobalCommands_insert("FaceCopyTexture", FreeCaller<SelectedFaces_copyTexture>());
1714 GlobalCommands_insert("FacePasteTexture", FreeCaller<SelectedFaces_pasteTexture>());
1716 GlobalCommands_insert("MakeDetail", FreeCaller<Select_MakeDetail>(), Accelerator('M', (GdkModifierType)GDK_CONTROL_MASK));
1717 GlobalCommands_insert("MakeStructural", FreeCaller<Select_MakeStructural>(), Accelerator('S', (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK)));
1720 void Brush_constructMenu(GtkMenu* menu)
1722 create_menu_item_with_mnemonic(menu, "Prism...", "BrushPrism");
1723 create_menu_item_with_mnemonic(menu, "Cone...", "BrushCone");
1724 create_menu_item_with_mnemonic(menu, "Sphere...", "BrushSphere");
1725 menu_separator (menu);
1727 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "CSG");
1728 create_menu_item_with_mnemonic(menu_in_menu, "Make _Hollow", "CSGHollow");
1729 create_menu_item_with_mnemonic(menu_in_menu, "CSG _Subtract", "CSGSubtract");
1730 create_menu_item_with_mnemonic(menu_in_menu, "CSG _Merge", "CSGMerge");
1732 menu_separator(menu);
1734 GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic (menu, "Clipper");
1736 create_menu_item_with_mnemonic(menu_in_menu, "Clip selection", "ClipSelected");
1737 create_menu_item_with_mnemonic(menu_in_menu, "Split selection", "SplitSelected");
1738 create_menu_item_with_mnemonic(menu_in_menu, "Flip Clip orientation", "FlipClip");
1740 menu_separator(menu);
1741 create_menu_item_with_mnemonic(menu, "Make detail", "MakeDetail");
1742 create_menu_item_with_mnemonic(menu, "Make structural", "MakeStructural");
1744 create_check_menu_item_with_mnemonic(menu, "Texture Lock", "TogTexLock");
1745 menu_separator(menu);
1746 create_menu_item_with_mnemonic(menu, "Copy Face Texture", "FaceCopyTexture");
1747 create_menu_item_with_mnemonic(menu, "Paste Face Texture", "FacePasteTexture");
1749 command_connect_accelerator("Brush3Sided");
1750 command_connect_accelerator("Brush4Sided");
1751 command_connect_accelerator("Brush5Sided");
1752 command_connect_accelerator("Brush6Sided");
1753 command_connect_accelerator("Brush7Sided");
1754 command_connect_accelerator("Brush8Sided");
1755 command_connect_accelerator("Brush9Sided");