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"
39 #include <gdk/gdkkeysyms.h>
41 void Brush_ConstructCuboid( Brush& brush, const AABB& bounds, const char* shader, const TextureProjection& projection ){
42 const unsigned char box[3][2] = { { 0, 1 }, { 2, 0 }, { 1, 2 } };
43 Vector3 mins( vector3_subtracted( bounds.origin, bounds.extents ) );
44 Vector3 maxs( vector3_added( bounds.origin, bounds.extents ) );
50 for ( int i = 0; i < 3; ++i )
52 Vector3 planepts1( maxs );
53 Vector3 planepts2( maxs );
54 planepts2[box[i][0]] = mins[box[i][0]];
55 planepts1[box[i][1]] = mins[box[i][1]];
57 brush.addPlane( maxs, planepts1, planepts2, shader, projection );
61 for ( int i = 0; i < 3; ++i )
63 Vector3 planepts1( mins );
64 Vector3 planepts2( mins );
65 planepts1[box[i][0]] = maxs[box[i][0]];
66 planepts2[box[i][1]] = maxs[box[i][1]];
68 brush.addPlane( mins, planepts1, planepts2, shader, projection );
73 inline float max_extent( const Vector3& extents ){
74 return std::max( std::max( extents[0], extents[1] ), extents[2] );
77 inline float max_extent_2d( const Vector3& extents, int axis ){
81 return std::max( extents[1], extents[2] );
83 return std::max( extents[0], extents[2] );
85 return std::max( extents[0], extents[1] );
89 const std::size_t c_brushPrism_minSides = 3;
90 const std::size_t c_brushPrism_maxSides = c_brush_maxFaces - 2;
91 const char* const c_brushPrism_name = "brushPrism";
93 void Brush_ConstructPrism( Brush& brush, const AABB& bounds, std::size_t sides, int axis, const char* shader, const TextureProjection& projection ){
94 if ( sides < c_brushPrism_minSides ) {
95 globalErrorStream() << c_brushPrism_name << ": sides " << Unsigned( sides ) << ": too few sides, minimum is " << Unsigned( c_brushPrism_minSides ) << "\n";
98 if ( sides > c_brushPrism_maxSides ) {
99 globalErrorStream() << c_brushPrism_name << ": sides " << Unsigned( sides ) << ": too many sides, maximum is " << Unsigned( c_brushPrism_maxSides ) << "\n";
104 brush.reserve( sides + 2 );
106 Vector3 mins( vector3_subtracted( bounds.origin, bounds.extents ) );
107 Vector3 maxs( vector3_added( bounds.origin, bounds.extents ) );
109 float radius = max_extent_2d( bounds.extents, axis );
110 const Vector3& mid = bounds.origin;
113 planepts[2][( axis + 1 ) % 3] = mins[( axis + 1 ) % 3];
114 planepts[2][( axis + 2 ) % 3] = mins[( axis + 2 ) % 3];
115 planepts[2][axis] = maxs[axis];
116 planepts[1][( axis + 1 ) % 3] = maxs[( axis + 1 ) % 3];
117 planepts[1][( axis + 2 ) % 3] = mins[( axis + 2 ) % 3];
118 planepts[1][axis] = maxs[axis];
119 planepts[0][( axis + 1 ) % 3] = maxs[( axis + 1 ) % 3];
120 planepts[0][( axis + 2 ) % 3] = maxs[( axis + 2 ) % 3];
121 planepts[0][axis] = maxs[axis];
123 brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
125 planepts[0][( axis + 1 ) % 3] = mins[( axis + 1 ) % 3];
126 planepts[0][( axis + 2 ) % 3] = mins[( axis + 2 ) % 3];
127 planepts[0][axis] = mins[axis];
128 planepts[1][( axis + 1 ) % 3] = maxs[( axis + 1 ) % 3];
129 planepts[1][( axis + 2 ) % 3] = mins[( axis + 2 ) % 3];
130 planepts[1][axis] = mins[axis];
131 planepts[2][( axis + 1 ) % 3] = maxs[( axis + 1 ) % 3];
132 planepts[2][( axis + 2 ) % 3] = maxs[( axis + 2 ) % 3];
133 planepts[2][axis] = mins[axis];
135 brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
137 for ( std::size_t i = 0 ; i < sides ; ++i )
139 double sv = sin( i * 3.14159265 * 2 / sides );
140 double cv = cos( i * 3.14159265 * 2 / sides );
142 // planepts[0][( axis + 1 ) % 3] = static_cast<float>( floor( mid[( axis + 1 ) % 3] + radius * cv + 0.5 ) );
143 // planepts[0][( axis + 2 ) % 3] = static_cast<float>( floor( mid[( axis + 2 ) % 3] + radius * sv + 0.5 ) );
144 planepts[0][( axis + 1 ) % 3] = static_cast<float>( mid[( axis + 1 ) % 3] + radius * cv );
145 planepts[0][( axis + 2 ) % 3] = static_cast<float>( mid[( axis + 2 ) % 3] + radius * sv );
146 planepts[0][axis] = mins[axis];
148 planepts[1][( axis + 1 ) % 3] = planepts[0][( axis + 1 ) % 3];
149 planepts[1][( axis + 2 ) % 3] = planepts[0][( axis + 2 ) % 3];
150 planepts[1][axis] = maxs[axis];
152 // planepts[2][( axis + 1 ) % 3] = static_cast<float>( floor( planepts[0][( axis + 1 ) % 3] - radius * sv + 0.5 ) );
153 // planepts[2][( axis + 2 ) % 3] = static_cast<float>( floor( planepts[0][( axis + 2 ) % 3] + radius * cv + 0.5 ) );
154 planepts[2][( axis + 1 ) % 3] = static_cast<float>( planepts[0][( axis + 1 ) % 3] - radius * sv );
155 planepts[2][( axis + 2 ) % 3] = static_cast<float>( planepts[0][( axis + 2 ) % 3] + radius * cv );
156 planepts[2][axis] = maxs[axis];
157 //globalOutputStream() << planepts[0] << " " << planepts[2] << " #" << i << " sin " << sv << " cos " << cv << "\n";
159 brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
163 const std::size_t c_brushCone_minSides = 3;
164 const std::size_t c_brushCone_maxSides = c_brush_maxFaces - 1;
165 const char* const c_brushCone_name = "brushCone";
167 void Brush_ConstructCone( Brush& brush, const AABB& bounds, std::size_t sides, const char* shader, const TextureProjection& projection ){
168 if ( sides < c_brushCone_minSides ) {
169 globalErrorStream() << c_brushCone_name << ": sides " << Unsigned( sides ) << ": too few sides, minimum is " << Unsigned( c_brushCone_minSides ) << "\n";
172 if ( sides > c_brushCone_maxSides ) {
173 globalErrorStream() << c_brushCone_name << ": sides " << Unsigned( sides ) << ": too many sides, maximum is " << Unsigned( c_brushCone_maxSides ) << "\n";
178 brush.reserve( sides + 1 );
180 Vector3 mins( vector3_subtracted( bounds.origin, bounds.extents ) );
181 Vector3 maxs( vector3_added( bounds.origin, bounds.extents ) );
183 float radius = max_extent( bounds.extents );
184 const Vector3& mid = bounds.origin;
187 planepts[0][0] = mins[0]; planepts[0][1] = mins[1]; planepts[0][2] = mins[2];
188 planepts[1][0] = maxs[0]; planepts[1][1] = mins[1]; planepts[1][2] = mins[2];
189 planepts[2][0] = maxs[0]; planepts[2][1] = maxs[1]; planepts[2][2] = mins[2];
191 brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
193 for ( std::size_t i = 0 ; i < sides ; ++i )
195 double sv = sin( i * 3.14159265 * 2 / sides );
196 double cv = cos( i * 3.14159265 * 2 / sides );
198 planepts[0][0] = static_cast<float>( mid[0] + radius * cv );
199 planepts[0][1] = static_cast<float>( mid[1] + radius * sv );
200 // planepts[0][0] = static_cast<float>( floor( mid[0] + radius * cv + 0.5 ) );
201 // planepts[0][1] = static_cast<float>( floor( mid[1] + radius * sv + 0.5 ) );
202 planepts[0][2] = mins[2];
204 planepts[1][0] = mid[0];
205 planepts[1][1] = mid[1];
206 planepts[1][2] = maxs[2];
208 planepts[2][0] = static_cast<float>( planepts[0][0] - radius * sv );
209 planepts[2][1] = static_cast<float>( planepts[0][1] + radius * cv );
210 // planepts[2][0] = static_cast<float>( floor( planepts[0][0] - radius * sv + 0.5 ) );
211 // planepts[2][1] = static_cast<float>( floor( planepts[0][1] + radius * cv + 0.5 ) );
212 planepts[2][2] = maxs[2];
214 brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
218 const std::size_t c_brushSphere_minSides = 3;
219 const std::size_t c_brushSphere_maxSides = 31;
220 const char* const c_brushSphere_name = "brushSphere";
222 void Brush_ConstructSphere( Brush& brush, const AABB& bounds, std::size_t sides, const char* shader, const TextureProjection& projection ){
223 if ( sides < c_brushSphere_minSides ) {
224 globalErrorStream() << c_brushSphere_name << ": sides " << Unsigned( sides ) << ": too few sides, minimum is " << Unsigned( c_brushSphere_minSides ) << "\n";
227 if ( sides > c_brushSphere_maxSides ) {
228 globalErrorStream() << c_brushSphere_name << ": sides " << Unsigned( sides ) << ": too many sides, maximum is " << Unsigned( c_brushSphere_maxSides ) << "\n";
233 brush.reserve( sides * sides );
235 float radius = max_extent( bounds.extents );
236 const Vector3& mid = bounds.origin;
239 double dt = 2 * c_pi / sides;
240 double dp = c_pi / sides;
241 for ( std::size_t i = 0; i < sides; i++ )
243 for ( std::size_t j = 0; j < sides - 1; j++ )
246 double p = float(j * dp - c_pi / 2);
248 planepts[0] = vector3_added( mid, vector3_scaled( vector3_for_spherical( t, p ), radius ) );
249 planepts[1] = vector3_added( mid, vector3_scaled( vector3_for_spherical( t, p + dp ), radius ) );
250 planepts[2] = vector3_added( mid, vector3_scaled( vector3_for_spherical( t + dt, p + dp ), radius ) );
252 brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
257 double p = ( sides - 1 ) * dp - c_pi / 2;
258 for ( std::size_t i = 0; i < sides; i++ )
262 planepts[0] = vector3_added( mid, vector3_scaled( vector3_for_spherical( t, p ), radius ) );
263 planepts[1] = vector3_added( mid, vector3_scaled( vector3_for_spherical( t + dt, p + dp ), radius ) );
264 planepts[2] = vector3_added( mid, vector3_scaled( vector3_for_spherical( t + dt, p ), radius ) );
266 brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
271 const std::size_t c_brushRock_minSides = 10;
272 const std::size_t c_brushRock_maxSides = 1000;
273 const char* const c_brushRock_name = "brushRock";
275 void Brush_ConstructRock( Brush& brush, const AABB& bounds, std::size_t sides, const char* shader, const TextureProjection& projection ){
276 if ( sides < c_brushRock_minSides ) {
277 globalErrorStream() << c_brushRock_name << ": sides " << Unsigned( sides ) << ": too few sides, minimum is " << Unsigned( c_brushRock_minSides ) << "\n";
280 if ( sides > c_brushRock_maxSides ) {
281 globalErrorStream() << c_brushRock_name << ": sides " << Unsigned( sides ) << ": too many sides, maximum is " << Unsigned( c_brushRock_maxSides ) << "\n";
286 brush.reserve( sides * sides );
288 float radius = max_extent( bounds.extents );
289 const Vector3& mid = bounds.origin;
292 for ( std::size_t j = 0; j < sides; j++ )
294 planepts[0][0] = rand() - ( RAND_MAX / 2 );
295 planepts[0][1] = rand() - ( RAND_MAX / 2 );
296 planepts[0][2] = rand() - ( RAND_MAX / 2 );
297 vector3_normalise( planepts[0] );
299 // find two vectors that are perpendicular to planepts[0]
300 ComputeAxisBase( planepts[0], planepts[1], planepts[2] );
302 planepts[0] = vector3_added( mid, vector3_scaled( planepts[0], radius ) );
303 planepts[1] = vector3_added( planepts[0], vector3_scaled( planepts[1], radius ) );
304 planepts[2] = vector3_added( planepts[0], vector3_scaled( planepts[2], radius ) );
307 // make sure the orientation is right
308 if ( vector3_dot( vector3_subtracted( planepts[0], mid ), vector3_cross( vector3_subtracted( planepts[1], mid ), vector3_subtracted( planepts[2], mid ) ) ) > 0 ) {
311 planepts[1] = planepts[2];
313 globalOutputStream() << "flip\n";
316 globalOutputStream() << "no flip\n";
320 brush.addPlane( planepts[0], planepts[1], planepts[2], shader, projection );
325 switch ( GlobalXYWnd_getCurrentViewType() )
337 void Brush_ConstructPrefab( Brush& brush, EBrushPrefab type, const AABB& bounds, std::size_t sides, const char* shader, const TextureProjection& projection ){
342 UndoableCommand undo( "brushCuboid" );
344 Brush_ConstructCuboid( brush, bounds, shader, projection );
349 int axis = GetViewAxis();
350 StringOutputStream command;
351 command << c_brushPrism_name << " -sides " << Unsigned( sides ) << " -axis " << axis;
352 UndoableCommand undo( command.c_str() );
354 Brush_ConstructPrism( brush, bounds, sides, axis, shader, projection );
359 StringOutputStream command;
360 command << c_brushCone_name << " -sides " << Unsigned( sides );
361 UndoableCommand undo( command.c_str() );
363 Brush_ConstructCone( brush, bounds, sides, shader, projection );
368 StringOutputStream command;
369 command << c_brushSphere_name << " -sides " << Unsigned( sides );
370 UndoableCommand undo( command.c_str() );
372 Brush_ConstructSphere( brush, bounds, sides, shader, projection );
377 StringOutputStream command;
378 command << c_brushRock_name << " -sides " << Unsigned( sides );
379 UndoableCommand undo( command.c_str() );
381 Brush_ConstructRock( brush, bounds, sides, shader, projection );
388 void ConstructRegionBrushes( scene::Node* brushes[6], const Vector3& region_mins, const Vector3& region_maxs ){
391 Vector3 mins( region_mins[0] - 32, region_mins[1] - 32, region_mins[2] - 32 );
394 for ( std::size_t i = 0; i < 3; i++ )
396 Vector3 maxs( region_maxs[0] + 32, region_maxs[1] + 32, region_maxs[2] + 32 );
397 maxs[i] = region_mins[i];
398 Brush_ConstructCuboid( *Node_getBrush( *brushes[i] ), aabb_for_minmax( mins, maxs ), texdef_name_default(), TextureProjection() );
404 Vector3 maxs( region_maxs[0] + 32, region_maxs[1] + 32, region_maxs[2] + 32 );
407 for ( std::size_t i = 0; i < 3; i++ )
409 Vector3 mins( region_mins[0] - 32, region_mins[1] - 32, region_mins[2] - 32 );
410 mins[i] = region_maxs[i];
411 Brush_ConstructCuboid( *Node_getBrush( *brushes[i + 3] ), aabb_for_minmax( mins, maxs ), texdef_name_default(), TextureProjection() );
417 void Scene_BrushSetTexdef_Selected( scene::Graph& graph, const TextureProjection& projection ){
418 Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
419 face.SetTexdef(projection);
424 void Scene_BrushSetTexdef_Component_Selected( scene::Graph& graph, const TextureProjection& projection ){
425 Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
426 face.SetTexdef(projection);
436 const ContentsFlagsValue& m_flags;
438 FaceSetFlags( const ContentsFlagsValue& flags ) : m_flags( flags ){
440 void operator()( Face& face ) const {
441 face.SetFlags( m_flags );
445 >>>>>>> 3a78d902017a780e65f21f12c709aa746dfcab84
446 void Scene_BrushSetFlags_Selected( scene::Graph& graph, const ContentsFlagsValue& flags ){
447 Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
448 face.SetFlags(flags);
453 void Scene_BrushSetFlags_Component_Selected( scene::Graph& graph, const ContentsFlagsValue& flags ){
454 Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
455 face.SetFlags(flags);
460 void Scene_BrushShiftTexdef_Selected( scene::Graph& graph, float s, float t ){
461 Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
462 face.ShiftTexdef(s, t);
467 void Scene_BrushShiftTexdef_Component_Selected( scene::Graph& graph, float s, float t ){
468 Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
469 face.ShiftTexdef(s, t);
474 void Scene_BrushScaleTexdef_Selected( scene::Graph& graph, float s, float t ){
475 Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
476 face.ScaleTexdef(s, t);
481 void Scene_BrushScaleTexdef_Component_Selected( scene::Graph& graph, float s, float t ){
482 Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
483 face.ScaleTexdef(s, t);
488 void Scene_BrushRotateTexdef_Selected( scene::Graph& graph, float angle ){
489 Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
490 face.RotateTexdef(angle);
495 void Scene_BrushRotateTexdef_Component_Selected( scene::Graph& graph, float angle ){
496 Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
497 face.RotateTexdef(angle);
503 void Scene_BrushSetShader_Selected( scene::Graph& graph, const char* name ){
504 Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
505 face.SetShader(name);
510 void Scene_BrushSetShader_Component_Selected( scene::Graph& graph, const char* name ){
511 Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
512 face.SetShader(name);
517 void Scene_BrushSetDetail_Selected( scene::Graph& graph, bool detail ){
518 Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
519 face.setDetail(detail);
524 bool Face_FindReplaceShader( Face& face, const char* find, const char* replace ){
525 if ( shader_equal( face.GetShader(), find ) ) {
526 face.SetShader( replace );
532 bool DoingSearch( const char *repl ){
533 return ( repl == NULL || ( strcmp( "textures/", repl ) == 0 ) );
536 void Scene_BrushFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){
537 if ( DoingSearch( replace ) ) {
538 Scene_ForEachBrush_ForEachFaceInstance(graph, [&](FaceInstance &faceinst) {
539 if (shader_equal(faceinst.getFace().GetShader(), find)) {
540 faceinst.setSelected(SelectionSystem::eFace, true);
546 Scene_ForEachBrush_ForEachFace(graph, [&](Face &face) { Face_FindReplaceShader(face, find, replace); });
550 void Scene_BrushFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){
551 if ( DoingSearch( replace ) ) {
552 Scene_ForEachSelectedBrush_ForEachFaceInstance(graph, [&](FaceInstance &faceinst) {
553 if (shader_equal(faceinst.getFace().GetShader(), find)) {
554 faceinst.setSelected(SelectionSystem::eFace, true);
560 Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
561 Face_FindReplaceShader(face, find, replace);
566 // TODO: find for components
567 // d1223m: dont even know what they are...
568 void Scene_BrushFindReplaceShader_Component_Selected( scene::Graph& graph, const char* find, const char* replace ){
569 if ( DoingSearch( replace ) ) {
574 Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
575 Face_FindReplaceShader(face, find, replace);
581 void Scene_BrushFitTexture_Selected( scene::Graph& graph, float s_repeat, float t_repeat ){
582 Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
583 face.FitTexture(s_repeat, t_repeat);
588 void Scene_BrushFitTexture_Component_Selected( scene::Graph& graph, float s_repeat, float t_repeat ){
589 Scene_ForEachSelectedBrushFace(graph, [&](Face &face) {
590 face.FitTexture(s_repeat, t_repeat);
595 TextureProjection g_defaultTextureProjection;
597 const TextureProjection& TextureTransform_getDefault(){
598 TexDef_Construct_Default( g_defaultTextureProjection );
599 return g_defaultTextureProjection;
602 void Scene_BrushConstructPrefab( scene::Graph& graph, EBrushPrefab type, std::size_t sides, const char* shader ){
603 if ( GlobalSelectionSystem().countSelected() != 0 ) {
604 const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
606 Brush* brush = Node_getBrush( path.top() );
608 AABB bounds = brush->localAABB(); // copy bounds because the brush will be modified
609 Brush_ConstructPrefab( *brush, type, bounds, sides, shader, TextureTransform_getDefault() );
615 void Scene_BrushResize_Selected( scene::Graph& graph, const AABB& bounds, const char* shader ){
616 if ( GlobalSelectionSystem().countSelected() != 0 ) {
617 const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
619 Brush* brush = Node_getBrush( path.top() );
621 Brush_ConstructCuboid( *brush, bounds, shader, TextureTransform_getDefault() );
627 bool Brush_hasShader( const Brush& brush, const char* name ){
628 for ( Brush::const_iterator i = brush.begin(); i != brush.end(); ++i )
630 if ( shader_equal( ( *i )->GetShader(), name ) ) {
637 class BrushSelectByShaderWalker : public scene::Graph::Walker
641 BrushSelectByShaderWalker( const char* name )
645 bool pre( const scene::Path& path, scene::Instance& instance ) const {
646 if ( path.top().get().visible() ) {
647 Brush* brush = Node_getBrush( path.top() );
648 if ( brush != 0 && Brush_hasShader( *brush, m_name ) ) {
649 Instance_getSelectable( instance )->setSelected( true );
659 void Scene_BrushSelectByShader( scene::Graph& graph, const char* name ){
660 graph.traverse( BrushSelectByShaderWalker( name ) );
663 void Scene_BrushSelectByShader_Component( scene::Graph& graph, const char* name ){
664 Scene_ForEachSelectedBrush_ForEachFaceInstance(graph, [&](FaceInstance &face) {
665 printf("checking %s = %s\n", face.getFace().GetShader(), name);
666 if (shader_equal(face.getFace().GetShader(), name)) {
667 face.setSelected( SelectionSystem::eFace, true );
672 void Scene_BrushGetTexdef_Selected( scene::Graph& graph, TextureProjection& projection ){
674 Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
677 face.GetTexdef(projection);
682 void Scene_BrushGetTexdef_Component_Selected( scene::Graph& graph, TextureProjection& projection ){
684 if ( !g_SelectedFaceInstances.empty() ) {
685 FaceInstance& faceInstance = g_SelectedFaceInstances.last();
686 faceInstance.getFace().GetTexdef( projection );
689 FaceGetTexdef visitor( projection );
690 Scene_ForEachSelectedBrushFace( graph, visitor );
694 void Scene_BrushGetShaderSize_Component_Selected( scene::Graph& graph, size_t& width, size_t& height ){
695 if ( !g_SelectedFaceInstances.empty() ) {
696 FaceInstance& faceInstance = g_SelectedFaceInstances.last();
697 width = faceInstance.getFace().getShader().width();
698 height = faceInstance.getFace().getShader().height();
703 void Scene_BrushGetFlags_Selected( scene::Graph& graph, ContentsFlagsValue& flags ){
705 if ( GlobalSelectionSystem().countSelected() != 0 ) {
706 BrushInstance* brush = Instance_getBrush( GlobalSelectionSystem().ultimateSelected() );
709 Brush_forEachFace(*brush, [&](Face &face) {
712 face.GetFlags(flags);
718 Scene_ForEachSelectedBrush_ForEachFace( graph, FaceGetFlags( flags ) );
722 void Scene_BrushGetFlags_Component_Selected( scene::Graph& graph, ContentsFlagsValue& flags ){
724 if ( !g_SelectedFaceInstances.empty() ) {
725 FaceInstance& faceInstance = g_SelectedFaceInstances.last();
726 faceInstance.getFace().GetFlags( flags );
729 Scene_ForEachSelectedBrushFace( graph, FaceGetFlags( flags ) );
734 void Scene_BrushGetShader_Selected( scene::Graph& graph, CopiedString& shader ){
736 if ( GlobalSelectionSystem().countSelected() != 0 ) {
737 BrushInstance* brush = Instance_getBrush( GlobalSelectionSystem().ultimateSelected() );
740 Brush_forEachFace(*brush, [&](Face &face) {
743 shader = face.GetShader();
749 Scene_ForEachSelectedBrush_ForEachFace( graph, FaceGetShader( shader ) );
753 void Scene_BrushGetShader_Component_Selected( scene::Graph& graph, CopiedString& shader ){
755 if ( !g_SelectedFaceInstances.empty() ) {
756 FaceInstance& faceInstance = g_SelectedFaceInstances.last();
757 shader = faceInstance.getFace().GetShader();
760 FaceGetShader visitor( shader );
761 Scene_ForEachSelectedBrushFace( graph, visitor );
766 class filter_face_shader : public FaceFilter
768 const char* m_shader;
770 filter_face_shader( const char* shader ) : m_shader( shader ){
773 bool filter( const Face& face ) const {
774 return shader_equal( face.GetShader(), m_shader );
778 class filter_face_shader_prefix : public FaceFilter
780 const char* m_prefix;
782 filter_face_shader_prefix( const char* prefix ) : m_prefix( prefix ){
785 bool filter( const Face& face ) const {
786 return shader_equal_n( face.GetShader(), m_prefix, strlen( m_prefix ) );
790 class filter_face_flags : public FaceFilter
794 filter_face_flags( int flags ) : m_flags( flags ){
797 bool filter( const Face& face ) const {
798 return ( face.getShader().shaderFlags() & m_flags ) != 0;
802 class filter_face_contents : public FaceFilter
806 filter_face_contents( int contents ) : m_contents( contents ){
809 bool filter( const Face& face ) const {
810 return ( face.getShader().m_flags.m_contentFlags & m_contents ) != 0;
816 class filter_brush_any_face : public BrushFilter
818 FaceFilter* m_filter;
820 filter_brush_any_face( FaceFilter* filter ) : m_filter( filter ){
823 bool filter( const Brush& brush ) const {
824 bool filtered = false;
825 Brush_forEachFace(brush, [&](Face &face) {
826 if (m_filter->filter(face)) {
834 class filter_brush_all_faces : public BrushFilter
836 FaceFilter* m_filter;
838 filter_brush_all_faces( FaceFilter* filter ) : m_filter( filter ){
840 bool filter( const Brush& brush ) const {
841 bool filtered = true;
842 Brush_forEachFace(brush, [&](Face &face) {
843 if (!m_filter->filter(face)) {
852 filter_face_flags g_filter_face_clip( QER_CLIP );
853 filter_brush_all_faces g_filter_brush_clip( &g_filter_face_clip );
855 filter_face_shader g_filter_face_clip_q2( "textures/clip" );
856 filter_brush_all_faces g_filter_brush_clip_q2( &g_filter_face_clip_q2 );
858 filter_face_shader g_filter_face_weapclip( "textures/common/weapclip" );
859 filter_brush_all_faces g_filter_brush_weapclip( &g_filter_face_weapclip );
861 filter_face_shader g_filter_face_commonclip( "textures/common/clip" );
862 filter_brush_all_faces g_filter_brush_commonclip( &g_filter_face_commonclip );
864 filter_face_shader g_filter_face_fullclip( "textures/common/fullclip" );
865 filter_brush_all_faces g_filter_brush_fullclip( &g_filter_face_fullclip );
867 filter_face_shader g_filter_face_botclip( "textures/common/botclip" );
868 filter_brush_all_faces g_filter_brush_botclip( &g_filter_face_botclip );
870 filter_face_shader_prefix g_filter_face_caulk( "textures/common/caulk" );
871 filter_brush_all_faces g_filter_brush_caulk( &g_filter_face_caulk );
873 filter_face_shader_prefix g_filter_face_caulk_ja( "textures/system/caulk" );
874 filter_brush_all_faces g_filter_brush_caulk_ja( &g_filter_face_caulk_ja );
876 filter_face_flags g_filter_face_liquids( QER_LIQUID );
877 filter_brush_any_face g_filter_brush_liquids( &g_filter_face_liquids );
879 filter_face_shader_prefix g_filter_face_liquidsdir( "textures/liquids/" );
880 filter_brush_any_face g_filter_brush_liquidsdir( &g_filter_face_liquidsdir );
882 filter_face_shader g_filter_face_hint( "textures/common/hint" );
883 filter_brush_any_face g_filter_brush_hint( &g_filter_face_hint );
885 filter_face_shader g_filter_face_hintlocal( "textures/common/hintlocal" );
886 filter_brush_any_face g_filter_brush_hintlocal( &g_filter_face_hintlocal );
888 filter_face_shader g_filter_face_hint_q2( "textures/hint" );
889 filter_brush_any_face g_filter_brush_hint_q2( &g_filter_face_hint_q2 );
891 filter_face_shader g_filter_face_hint_ja( "textures/system/hint" );
892 filter_brush_any_face g_filter_brush_hint_ja( &g_filter_face_hint_ja );
894 filter_face_shader g_filter_face_areaportal( "textures/common/areaportal" );
895 filter_brush_any_face g_filter_brush_areaportal( &g_filter_face_areaportal );
897 filter_face_shader g_filter_face_visportal( "textures/editor/visportal" );
898 filter_brush_any_face g_filter_brush_visportal( &g_filter_face_visportal );
900 filter_face_shader g_filter_face_clusterportal( "textures/common/clusterportal" );
901 filter_brush_all_faces g_filter_brush_clusterportal( &g_filter_face_clusterportal );
903 filter_face_shader g_filter_face_lightgrid( "textures/common/lightgrid" );
904 filter_brush_all_faces g_filter_brush_lightgrid( &g_filter_face_lightgrid );
906 filter_face_flags g_filter_face_translucent( QER_TRANS | QER_ALPHATEST );
907 filter_brush_any_face g_filter_brush_translucent( &g_filter_face_translucent );
909 filter_face_contents g_filter_face_detail( BRUSH_DETAIL_MASK );
910 filter_brush_all_faces g_filter_brush_detail( &g_filter_face_detail );
912 filter_face_shader_prefix g_filter_face_decals( "textures/decals/" );
913 filter_brush_any_face g_filter_brush_decals( &g_filter_face_decals );
916 void BrushFilters_construct(){
917 add_brush_filter( g_filter_brush_clip, EXCLUDE_CLIP );
918 add_brush_filter( g_filter_brush_clip_q2, EXCLUDE_CLIP );
919 add_brush_filter( g_filter_brush_weapclip, EXCLUDE_CLIP );
920 add_brush_filter( g_filter_brush_fullclip, EXCLUDE_CLIP );
921 add_brush_filter( g_filter_brush_commonclip, EXCLUDE_CLIP );
922 add_brush_filter( g_filter_brush_botclip, EXCLUDE_BOTCLIP );
923 add_brush_filter( g_filter_brush_caulk, EXCLUDE_CAULK );
924 add_brush_filter( g_filter_brush_caulk_ja, EXCLUDE_CAULK );
925 add_face_filter( g_filter_face_caulk, EXCLUDE_CAULK );
926 add_face_filter( g_filter_face_caulk_ja, EXCLUDE_CAULK );
927 add_brush_filter( g_filter_brush_liquids, EXCLUDE_LIQUIDS );
928 add_brush_filter( g_filter_brush_liquidsdir, EXCLUDE_LIQUIDS );
929 add_brush_filter( g_filter_brush_hint, EXCLUDE_HINTSSKIPS );
930 add_brush_filter( g_filter_brush_hintlocal, EXCLUDE_HINTSSKIPS );
931 add_brush_filter( g_filter_brush_hint_q2, EXCLUDE_HINTSSKIPS );
932 add_brush_filter( g_filter_brush_hint_ja, EXCLUDE_HINTSSKIPS );
933 add_brush_filter( g_filter_brush_clusterportal, EXCLUDE_CLUSTERPORTALS );
934 add_brush_filter( g_filter_brush_visportal, EXCLUDE_VISPORTALS );
935 add_brush_filter( g_filter_brush_areaportal, EXCLUDE_AREAPORTALS );
936 add_brush_filter( g_filter_brush_translucent, EXCLUDE_TRANSLUCENT );
937 add_brush_filter( g_filter_brush_detail, EXCLUDE_DETAILS );
938 add_brush_filter( g_filter_brush_detail, EXCLUDE_STRUCTURAL, true );
939 add_brush_filter( g_filter_brush_lightgrid, EXCLUDE_LIGHTGRID );
940 add_brush_filter( g_filter_brush_decals, EXCLUDE_DECALS );
945 void normalquantisation_draw(){
947 glBegin( GL_POINTS );
948 for ( std::size_t i = 0; i <= c_quantise_normal; ++i )
950 for ( std::size_t j = 0; j <= c_quantise_normal; ++j )
952 Normal3f vertex( normal3f_normalised( Normal3f(
953 static_cast<float>( c_quantise_normal - j - i ),
954 static_cast<float>( i ),
955 static_cast<float>( j )
957 VectorScale( normal3f_to_array( vertex ), 64.f, normal3f_to_array( vertex ) );
958 glVertex3fv( normal3f_to_array( vertex ) );
959 vertex.x = -vertex.x;
960 glVertex3fv( normal3f_to_array( vertex ) );
966 class RenderableNormalQuantisation : public OpenGLRenderable
969 void render( RenderStateFlags state ) const {
970 normalquantisation_draw();
974 const float g_test_quantise_normal = 1.f / static_cast<float>( 1 << 3 );
976 class TestNormalQuantisation
978 void check_normal( const Normal3f& normal, const Normal3f& other ){
979 spherical_t spherical = spherical_from_normal3f( normal );
980 double longditude = RAD2DEG( spherical.longditude );
981 double latitude = RAD2DEG( spherical.latitude );
982 double x = cos( spherical.longditude ) * sin( spherical.latitude );
983 double y = sin( spherical.longditude ) * sin( spherical.latitude );
984 double z = cos( spherical.latitude );
986 ASSERT_MESSAGE( normal3f_dot( normal, other ) > 0.99, "bleh" );
989 void test_normal( const Normal3f& normal ){
990 Normal3f test = normal3f_from_spherical( spherical_from_normal3f( normal ) );
991 check_normal( normal, test );
993 EOctant octant = normal3f_classify_octant( normal );
994 Normal3f folded = normal3f_fold_octant( normal, octant );
995 ESextant sextant = normal3f_classify_sextant( folded );
996 folded = normal3f_fold_sextant( folded, sextant );
998 double scale = static_cast<float>( c_quantise_normal ) / ( folded.x + folded.y + folded.z );
1000 double zbits = folded.z * scale;
1001 double ybits = folded.y * scale;
1003 std::size_t zbits_q = static_cast<std::size_t>( zbits );
1004 std::size_t ybits_q = static_cast<std::size_t>( ybits );
1006 ASSERT_MESSAGE( zbits_q <= ( c_quantise_normal / 8 ) * 3, "bleh" );
1007 ASSERT_MESSAGE( ybits_q <= ( c_quantise_normal / 2 ), "bleh" );
1008 ASSERT_MESSAGE( zbits_q + ( ( c_quantise_normal / 2 ) - ybits_q ) <= ( c_quantise_normal / 2 ), "bleh" );
1010 std::size_t y_t = ( zbits_q < ( c_quantise_normal / 4 ) ) ? ybits_q : ( c_quantise_normal / 2 ) - ybits_q;
1011 std::size_t z_t = ( zbits_q < ( c_quantise_normal / 4 ) ) ? zbits_q : ( c_quantise_normal / 2 ) - zbits_q;
1012 std::size_t index = ( c_quantise_normal / 4 ) * y_t + z_t;
1013 ASSERT_MESSAGE( index <= ( c_quantise_normal / 4 ) * ( c_quantise_normal / 2 ), "bleh" );
1015 Normal3f tmp( c_quantise_normal - zbits_q - ybits_q, ybits_q, zbits_q );
1016 tmp = normal3f_normalised( tmp );
1018 Normal3f unfolded = normal3f_unfold_octant( normal3f_unfold_sextant( tmp, sextant ), octant );
1020 check_normal( normal, unfolded );
1022 double dot = normal3f_dot( normal, unfolded );
1023 float length = VectorLength( normal3f_to_array( unfolded ) );
1024 float inv_length = 1 / length;
1026 Normal3f quantised = normal3f_quantised( normal );
1027 check_normal( normal, quantised );
1029 void test2( const Normal3f& normal, const Normal3f& other ){
1030 if ( normal3f_quantised( normal ) != normal3f_quantised( other ) ) {
1035 static Normal3f normalise( float x, float y, float z ){
1036 return normal3f_normalised( Normal3f( x, y, z ) );
1040 return static_cast<float>( rand() - ( RAND_MAX / 2 ) );
1043 Normal3f normal3f_rand(){
1044 return normalise( vec_rand(), vec_rand(), vec_rand() );
1048 TestNormalQuantisation(){
1049 for ( int i = 4096; i > 0; --i )
1050 test_normal( normal3f_rand() );
1052 test_normal( normalise( 1, 0, 0 ) );
1053 test_normal( normalise( 0, 1, 0 ) );
1054 test_normal( normalise( 0, 0, 1 ) );
1055 test_normal( normalise( 1, 1, 0 ) );
1056 test_normal( normalise( 1, 0, 1 ) );
1057 test_normal( normalise( 0, 1, 1 ) );
1059 test_normal( normalise( 10000, 10000, 10000 ) );
1060 test_normal( normalise( 10000, 10000, 10001 ) );
1061 test_normal( normalise( 10000, 10000, 10002 ) );
1062 test_normal( normalise( 10000, 10000, 10010 ) );
1063 test_normal( normalise( 10000, 10000, 10020 ) );
1064 test_normal( normalise( 10000, 10000, 10030 ) );
1065 test_normal( normalise( 10000, 10000, 10100 ) );
1066 test_normal( normalise( 10000, 10000, 10101 ) );
1067 test_normal( normalise( 10000, 10000, 10102 ) );
1068 test_normal( normalise( 10000, 10000, 10200 ) );
1069 test_normal( normalise( 10000, 10000, 10201 ) );
1070 test_normal( normalise( 10000, 10000, 10202 ) );
1071 test_normal( normalise( 10000, 10000, 10203 ) );
1072 test_normal( normalise( 10000, 10000, 10300 ) );
1075 test2( normalise( 10000, 10000, 10000 ), normalise( 10000, 10000, 10001 ) );
1076 test2( normalise( 10000, 10000, 10001 ), normalise( 10000, 10001, 10000 ) );
1080 TestNormalQuantisation g_testNormalQuantisation;
1086 class TestSelectableObserver : public observer_template<const Selectable&>
1089 void notify( const Selectable& arguments ){
1090 bool bleh = arguments.isSelected();
1094 inline void test_bleh(){
1095 TestSelectableObserver test;
1096 ObservableSelectableInstance< SingleObservable< SelectionChangeCallback > > bleh;
1097 bleh.attach( test );
1098 bleh.setSelected( true );
1099 bleh.detach( test );
1110 const TestBleh testbleh;
1115 class TestRefcountedString
1118 TestRefcountedString(){
1121 SmartString string1( "string1" );
1122 SmartString string2( string1 );
1123 SmartString string3( string2 );
1126 // refcounted assignment
1127 SmartString string1( "string1" );
1128 SmartString string2( "string2" );
1133 SmartString string1( "string1" );
1134 SmartString string2( "string2" );
1135 string1 = string2.c_str();
1139 SmartString string1( "string1" );
1143 // self-assignment via another reference
1144 SmartString string1( "string1" );
1145 SmartString string2( string1 );
1151 const TestRefcountedString g_testRefcountedString;
1155 void Select_MakeDetail(){
1156 UndoableCommand undo( "brushSetDetail" );
1157 Scene_BrushSetDetail_Selected( GlobalSceneGraph(), true );
1160 void Select_MakeStructural(){
1161 UndoableCommand undo( "brushClearDetail" );
1162 Scene_BrushSetDetail_Selected( GlobalSceneGraph(), false );
1165 class BrushMakeSided
1167 std::size_t m_count;
1169 BrushMakeSided( std::size_t count )
1174 Scene_BrushConstructPrefab( GlobalSceneGraph(), eBrushPrism, m_count, TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) );
1177 typedef MemberCaller<BrushMakeSided, void(), &BrushMakeSided::set> SetCaller;
1181 BrushMakeSided g_brushmakesided3( 3 );
1182 BrushMakeSided g_brushmakesided4( 4 );
1183 BrushMakeSided g_brushmakesided5( 5 );
1184 BrushMakeSided g_brushmakesided6( 6 );
1185 BrushMakeSided g_brushmakesided7( 7 );
1186 BrushMakeSided g_brushmakesided8( 8 );
1187 BrushMakeSided g_brushmakesided9( 9 );
1189 inline int axis_for_viewtype( int viewtype ){
1204 EBrushPrefab m_type;
1206 BrushPrefab( EBrushPrefab type )
1211 DoSides( m_type, axis_for_viewtype( GetViewAxis() ) );
1214 typedef MemberCaller<BrushPrefab, void(), &BrushPrefab::set> SetCaller;
1217 BrushPrefab g_brushprism( eBrushPrism );
1218 BrushPrefab g_brushcone( eBrushCone );
1219 BrushPrefab g_brushsphere( eBrushSphere );
1220 BrushPrefab g_brushrock( eBrushRock );
1229 void OnClipMode( bool enable );
1234 void ClipSelected(){
1236 UndoableCommand undo( "clipperClip" );
1241 void SplitSelected(){
1243 UndoableCommand undo( "clipperSplit" );
1253 Callback<void()> g_texture_lock_status_changed;
1254 ConstReferenceCaller<bool, void(const Callback<void(bool)> &), PropertyImpl<bool>::Export> g_texdef_movelock_caller( g_brush_texturelock_enabled );
1255 ToggleItem g_texdef_movelock_item( g_texdef_movelock_caller );
1257 void Texdef_ToggleMoveLock(){
1258 g_brush_texturelock_enabled = !g_brush_texturelock_enabled;
1259 g_texdef_movelock_item.update();
1260 g_texture_lock_status_changed();
1264 void Brush_registerCommands(){
1265 GlobalToggles_insert( "TogTexLock", makeCallbackF(Texdef_ToggleMoveLock), ToggleItem::AddCallbackCaller( g_texdef_movelock_item ), Accelerator( 'T', (GdkModifierType)GDK_SHIFT_MASK ) );
1267 GlobalCommands_insert( "BrushPrism", BrushPrefab::SetCaller( g_brushprism ) );
1268 GlobalCommands_insert( "BrushCone", BrushPrefab::SetCaller( g_brushcone ) );
1269 GlobalCommands_insert( "BrushSphere", BrushPrefab::SetCaller( g_brushsphere ) );
1270 GlobalCommands_insert( "BrushRock", BrushPrefab::SetCaller( g_brushrock ) );
1272 GlobalCommands_insert( "Brush3Sided", BrushMakeSided::SetCaller( g_brushmakesided3 ), Accelerator( '3', (GdkModifierType)GDK_CONTROL_MASK ) );
1273 GlobalCommands_insert( "Brush4Sided", BrushMakeSided::SetCaller( g_brushmakesided4 ), Accelerator( '4', (GdkModifierType)GDK_CONTROL_MASK ) );
1274 GlobalCommands_insert( "Brush5Sided", BrushMakeSided::SetCaller( g_brushmakesided5 ), Accelerator( '5', (GdkModifierType)GDK_CONTROL_MASK ) );
1275 GlobalCommands_insert( "Brush6Sided", BrushMakeSided::SetCaller( g_brushmakesided6 ), Accelerator( '6', (GdkModifierType)GDK_CONTROL_MASK ) );
1276 GlobalCommands_insert( "Brush7Sided", BrushMakeSided::SetCaller( g_brushmakesided7 ), Accelerator( '7', (GdkModifierType)GDK_CONTROL_MASK ) );
1277 GlobalCommands_insert( "Brush8Sided", BrushMakeSided::SetCaller( g_brushmakesided8 ), Accelerator( '8', (GdkModifierType)GDK_CONTROL_MASK ) );
1278 GlobalCommands_insert( "Brush9Sided", BrushMakeSided::SetCaller( g_brushmakesided9 ), Accelerator( '9', (GdkModifierType)GDK_CONTROL_MASK ) );
1280 GlobalCommands_insert( "ClipSelected", makeCallbackF(ClipSelected), Accelerator( GDK_KEY_Return ) );
1281 GlobalCommands_insert( "SplitSelected", makeCallbackF(SplitSelected), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_SHIFT_MASK ) );
1282 GlobalCommands_insert( "FlipClip", makeCallbackF(FlipClipper), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_CONTROL_MASK ) );
1284 GlobalCommands_insert( "MakeDetail", makeCallbackF(Select_MakeDetail), Accelerator( 'M', (GdkModifierType)GDK_CONTROL_MASK ) );
1285 GlobalCommands_insert( "MakeStructural", makeCallbackF(Select_MakeStructural), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
1288 void Brush_constructMenu( ui::Menu menu ){
1289 create_menu_item_with_mnemonic( menu, "Prism...", "BrushPrism" );
1290 create_menu_item_with_mnemonic( menu, "Cone...", "BrushCone" );
1291 create_menu_item_with_mnemonic( menu, "Sphere...", "BrushSphere" );
1292 create_menu_item_with_mnemonic( menu, "Rock...", "BrushRock" );
1293 menu_separator( menu );
1295 auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "CSG" );
1296 if ( g_Layout_enableDetachableMenus.m_value ) {
1297 menu_tearoff( menu_in_menu );
1299 create_menu_item_with_mnemonic( menu_in_menu, "CSG _Subtract", "CSGSubtract" );
1300 create_menu_item_with_mnemonic( menu_in_menu, "CSG _Merge", "CSGMerge" );
1301 create_menu_item_with_mnemonic( menu_in_menu, "Make _Room", "CSGRoom" );
1302 create_menu_item_with_mnemonic( menu_in_menu, "CSG _Tool", "CSGTool" );
1304 menu_separator( menu );
1306 auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Clipper" );
1307 if ( g_Layout_enableDetachableMenus.m_value ) {
1308 menu_tearoff( menu_in_menu );
1311 create_menu_item_with_mnemonic( menu_in_menu, "Clip selection", "ClipSelected" );
1312 create_menu_item_with_mnemonic( menu_in_menu, "Split selection", "SplitSelected" );
1313 create_menu_item_with_mnemonic( menu_in_menu, "Flip Clip orientation", "FlipClip" );
1315 menu_separator( menu );
1316 create_menu_item_with_mnemonic( menu, "Make detail", "MakeDetail" );
1317 create_menu_item_with_mnemonic( menu, "Make structural", "MakeStructural" );
1318 // create_menu_item_with_mnemonic( menu, "Snap selection to _grid", "SnapToGrid" );
1320 create_check_menu_item_with_mnemonic( menu, "Texture Lock", "TogTexLock" );
1321 menu_separator( menu );
1322 create_menu_item_with_mnemonic( menu, "Copy Face Texture", "FaceCopyTexture" );
1323 create_menu_item_with_mnemonic( menu, "Paste Face Texture", "FacePasteTexture" );
1325 command_connect_accelerator( "Brush3Sided" );
1326 command_connect_accelerator( "Brush4Sided" );
1327 command_connect_accelerator( "Brush5Sided" );
1328 command_connect_accelerator( "Brush6Sided" );
1329 command_connect_accelerator( "Brush7Sided" );
1330 command_connect_accelerator( "Brush8Sided" );
1331 command_connect_accelerator( "Brush9Sided" );