void Select_ScaleTexture(int x, int y) { brush_t *b; face_t *f; if(selected_brushes.next == &selected_brushes && selected_face == NULL) { return; } for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) { for (f=b->brush_faces ; f ; f=f->next) { f->texdef.scale[0] += x; f->texdef.scale[1] += y; } Brush_Build(b); if (b->patchBrush) Patch_ScaleTexture(b->nPatchID, x, y); } if (selected_face) { selected_face->texdef.scale[0] += x; selected_face->texdef.scale[1] += y; Brush_Build(selected_face_brush); } Sys_UpdateWindows (W_CAMERA); }
void Select_FitTexture( int nHeight, int nWidth ) { brush_s* b; int nFaceCount = g_ptrSelectedFaces.GetSize(); if ( selected_brushes.next == &selected_brushes && nFaceCount == 0 ) return; for ( b = selected_brushes.next ; b != &selected_brushes ; b = b->next ) { Brush_FitTexture( b, nHeight, nWidth ); Brush_Build( b ); } if ( nFaceCount > 0 ) { for ( int i = 0; i < nFaceCount; i++ ) { face_s* selFace = reinterpret_cast<face_s*>( g_ptrSelectedFaces.GetAt( i ) ); brush_s* selBrush = reinterpret_cast<brush_s*>( g_ptrSelectedFaceBrushes.GetAt( i ) ); Face_FitTexture( selFace, nHeight, nWidth ); Brush_Build( selBrush ); } } Sys_UpdateWindows( W_CAMERA ); }
void Select_RotateTexture(int amt) { brush_t *b; face_t *f; if(selected_brushes.next == &selected_brushes && selected_face == NULL) return; for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) { for (f=b->brush_faces ; f ; f=f->next) { f->texdef.rotate += amt; f->texdef.rotate = static_cast<int>(f->texdef.rotate) % 360; } Brush_Build(b); if (b->patchBrush) Patch_RotateTexture(b->nPatchID, amt); } if (selected_face) { selected_face->texdef.rotate += amt; selected_face->texdef.rotate = static_cast<int>(selected_face->texdef.rotate) % 360; Brush_Build(selected_face_brush); } Sys_UpdateWindows (W_CAMERA); }
void Select_ShiftTexture( int x, int y ) { brush_s* b; face_s* f; int nFaceCount = g_ptrSelectedFaces.GetSize(); if ( selected_brushes.next == &selected_brushes && nFaceCount == 0 ) return; for ( b = selected_brushes.next ; b != &selected_brushes ; b = b->next ) { for ( f = b->brush_faces ; f ; f = f->next ) { if ( g_qeglobals.m_bBrushPrimitMode ) { // use face normal to compute a true translation Select_ShiftTexture_BrushPrimit( f, x, y ); } else { f->texdef.shift[0] += x; f->texdef.shift[1] += y; } } Brush_Build( b ); if ( b->patchBrush ) { //Patch_ShiftTexture(b->nPatchID, x, y); Patch_ShiftTexture( b->pPatch, x, y ); } } if ( nFaceCount > 0 ) { for ( int i = 0; i < nFaceCount; i++ ) { face_s* selFace = reinterpret_cast<face_s*>( g_ptrSelectedFaces.GetAt( i ) ); brush_s* selBrush = reinterpret_cast<brush_s*>( g_ptrSelectedFaceBrushes.GetAt( i ) ); if ( g_qeglobals.m_bBrushPrimitMode ) { // use face normal to compute a true translation // Select_ShiftTexture_BrushPrimit( selected_face, x, y ); // use camera view to compute texture shift g_pParentWnd->GetCamera()->ShiftTexture_BrushPrimit( selFace, x, y ); } else { selFace->texdef.shift[0] += x; selFace->texdef.shift[1] += y; } Brush_Build( selBrush ); } } Sys_UpdateWindows( W_CAMERA ); }
void RotateTextures(int nAxis, float fDeg, vec3_t vOrigin) { for (brush_t* b=selected_brushes.next ; b != &selected_brushes ; b=b->next) { for (face_t* f=b->brush_faces ; f ; f=f->next) { RotateFaceTexture(f, nAxis, fDeg); Brush_Build(b, false); } Brush_Build(b, false); } }
/* ============== CSG_SplitBrushByFace The incoming brush is NOT freed. The incoming face is NOT left referenced. ============== */ void CSG_SplitBrushByFace (brush_t *in, face_t *f, brush_t **front, brush_t **back) { brush_t *b; face_t *nf; vec3_t temp; b = Brush_Clone (in); nf = Face_Clone (f); nf->texdef = b->brush_faces->texdef; nf->next = b->brush_faces; b->brush_faces = nf; Brush_Build( b ); Brush_RemoveEmptyFaces ( b ); if ( !b->brush_faces ) { // completely clipped away Brush_Free (b); *back = NULL; } else { Entity_LinkBrush (in->owner, b); *back = b; } b = Brush_Clone (in); nf = Face_Clone (f); // swap the plane winding VectorCopy (nf->planepts[0], temp); VectorCopy (nf->planepts[1], nf->planepts[0]); VectorCopy (temp, nf->planepts[1]); nf->texdef = b->brush_faces->texdef; nf->next = b->brush_faces; b->brush_faces = nf; Brush_Build( b ); Brush_RemoveEmptyFaces ( b ); if ( !b->brush_faces ) { // completely clipped away Brush_Free (b); *front = NULL; } else { Entity_LinkBrush (in->owner, b); *front = b; } }
/* Turn the currently selected entity back into normal brushes */ void Select_Ungroup (void) { entity_t *e; brush_t *b; e = selected_brushes.next->owner; if (!e || e == world_entity || e->eclass->fixedsize) { Sys_Status ("Not a grouped entity.", 0); return; } for (b=e->brushes.onext ; b != &e->brushes ; b=e->brushes.onext) { Brush_RemoveFromList (b); Brush_AddToList (b, &active_brushes); Entity_UnlinkBrush (b); Entity_LinkBrush (world_entity, b); Brush_Build( b ); b->owner = world_entity; } Entity_Free (e); Sys_UpdateWindows (W_ALL); }
void SI_FaceList_FitTexture(texdef_to_face_t* si_texdef_face_list, int nHeight, int nWidth) { texdef_to_face_t* temp_texdef_face_list; brushprimit_texdef_t bp; if (!si_texdef_face_list) return; for (temp_texdef_face_list = si_texdef_face_list; temp_texdef_face_list; temp_texdef_face_list = temp_texdef_face_list->next) { Face_FitTexture(temp_texdef_face_list->face, nHeight, nWidth); Brush_Build(temp_texdef_face_list->brush,true,true,false,false); // Write changes to our working Texdef list if(g_qeglobals.m_bBrushPrimitMode) { ConvertTexMatWithQTexture(&temp_texdef_face_list->face->brushprimit_texdef, QERApp_Shader_ForName( temp_texdef_face_list->face->texdef.GetName() )->getTexture(), &bp, NULL); TexMatToFakeTexCoords(bp.coords, temp_texdef_face_list->face->texdef.shift, &temp_texdef_face_list->face->texdef.rotate, temp_texdef_face_list->face->texdef.scale); } temp_texdef_face_list->texdef = temp_texdef_face_list->face->texdef; } Sys_UpdateWindows (W_CAMERA); }
void Select_AplyMatrix (void) { brush_t *b; face_t *f; int i, j; vec3_t temp; for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) { for (f=b->brush_faces ; f ; f=f->next) { for (i=0 ; i<3 ; i++) { Math_VectorSubtract(f->planepts[i],select_origin, temp); for (j=0 ; j<3 ; j++) f->planepts[i][j] = Math_DotProduct(temp,select_matrix[j]) + select_origin[j]; } if (select_fliporder) { Math_VectorCopy(f->planepts[0],temp); Math_VectorCopy(f->planepts[2],f->planepts[0]); Math_VectorCopy(temp,f->planepts[2]); } } Brush_Build( b ); } Sys_UpdateWindows (W_ALL); }
void FindReplaceTextures( const char* pFind, const char* pReplace, bool bSelected, bool bForce ) { brush_s* pList = ( bSelected ) ? &selected_brushes : &active_brushes; if ( !bSelected ) { Select_Deselect(); } for ( brush_s* pBrush = pList->next ; pBrush != pList; pBrush = pBrush->next ) { if ( pBrush->patchBrush ) { Patch_FindReplaceTexture( pBrush, pFind, pReplace, bForce ); } for ( face_s* pFace = pBrush->brush_faces; pFace; pFace = pFace->next ) { if ( bForce || strcmpi( pFace->texdef.name, pFind ) == 0 ) { pFace->d_texture = Texture_ForName( pReplace ); //strcpy(pFace->texdef.name, pReplace); pFace->texdef.SetName( pReplace ); } } Brush_Build( pBrush ); } Sys_UpdateWindows( W_CAMERA ); }
/* ============ Select_SetTexture Timo : bFitScale to compute scale on the plane and counteract plane / axial plane snapping Timo : brush primitive texturing the brushprimit_texdef given must be understood as a qtexture_t width=2 height=2 ( HiRes ) Timo : texture plugin, added an IPluginTexdef* parameter must be casted to an IPluginTexdef! if not NULL, get ->Copy() of it into each face or brush ( and remember to hook ) if NULL, means we have no information, ask for a default ============ */ void WINAPI Select_SetTexture( texdef_t* texdef, brushprimit_texdef_s* brushprimit_texdef, bool bFitScale, void* pPlugTexdef ) { brush_s* b; int nCount = g_ptrSelectedFaces.GetSize(); if ( nCount > 0 ) { Undo_Start( "set face textures" ); ASSERT( g_ptrSelectedFaces.GetSize() == g_ptrSelectedFaceBrushes.GetSize() ); for ( int i = 0; i < nCount; i++ ) { face_s* selFace = reinterpret_cast<face_s*>( g_ptrSelectedFaces.GetAt( i ) ); brush_s* selBrush = reinterpret_cast<brush_s*>( g_ptrSelectedFaceBrushes.GetAt( i ) ); Undo_AddBrush( selBrush ); SetFaceTexdef( selBrush, selFace, texdef, brushprimit_texdef, bFitScale, static_cast<IPluginTexdef*>( pPlugTexdef ) ); Brush_Build( selBrush, bFitScale ); Undo_EndBrush( selBrush ); } Undo_End(); } else if ( selected_brushes.next != &selected_brushes ) { Undo_Start( "set brush textures" ); for ( b = selected_brushes.next ; b != &selected_brushes ; b = b->next ) if ( !b->owner->eclass->fixedsize ) { Undo_AddBrush( b ); Brush_SetTexture( b, texdef, brushprimit_texdef, bFitScale, static_cast<IPluginTexdef*>( pPlugTexdef ) ); Undo_EndBrush( b ); } Undo_End(); } Sys_UpdateWindows( W_ALL ); }
void Select_AplyMatrix (bool bSnap) { brush_t *b; face_t *f; int i, j; vec3_t temp; for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) { for (f=b->brush_faces ; f ; f=f->next) { for (i=0 ; i<3 ; i++) { VectorSubtract (f->planepts[i], select_origin, temp); for (j=0 ; j<3 ; j++) f->planepts[i][j] = DotProduct(temp, select_matrix[j]) + select_origin[j]; } if (select_fliporder) { VectorCopy (f->planepts[0], temp); VectorCopy (f->planepts[2], f->planepts[0]); VectorCopy (temp, f->planepts[2]); } } Brush_Build(b, bSnap); if (b->patchBrush) { Patch_ApplyMatrix(b->nPatchID, select_origin, select_matrix); } } }
/* ======================================================================================================================= AddRegionBrushes a regioned map will have temp walls put up at the region boundary ======================================================================================================================= */ void AddRegionBrushes(void) { idVec3 mins, maxs; int i; texdef_t td; if (!region_active) { return; } memset(&td, 0, sizeof(td)); td = g_qeglobals.d_texturewin.texdef; // strcpy (td.name, "REGION"); td.SetName("textures/REGION"); const int REGION_WIDTH = 1024; mins[0] = region_mins[0] - REGION_WIDTH; maxs[0] = region_mins[0] + 1; mins[1] = region_mins[1] - REGION_WIDTH; maxs[1] = region_maxs[1] + REGION_WIDTH; mins[2] = MIN_WORLD_COORD; maxs[2] = MAX_WORLD_COORD; region_sides[0] = Brush_Create(mins, maxs, &td); mins[0] = region_maxs[0] - 1; maxs[0] = region_maxs[0] + REGION_WIDTH; region_sides[1] = Brush_Create(mins, maxs, &td); mins[0] = region_mins[0] - REGION_WIDTH; maxs[0] = region_maxs[0] + REGION_WIDTH; mins[1] = region_mins[1] - REGION_WIDTH; maxs[1] = region_mins[1] + 1; region_sides[2] = Brush_Create(mins, maxs, &td); mins[1] = region_maxs[1] - 1; maxs[1] = region_maxs[1] + REGION_WIDTH; region_sides[3] = Brush_Create(mins, maxs, &td); mins = region_mins; maxs = region_maxs; maxs[2] = mins[2] + REGION_WIDTH; region_sides[4] = Brush_Create(mins, maxs, &td); mins = region_mins; maxs = region_maxs; mins[2] = maxs[2] - REGION_WIDTH; region_sides[5] = Brush_Create(mins, maxs, &td); for (i = 0; i < 6; i++) { Brush_AddToList(region_sides[i], &selected_brushes); Entity_LinkBrush(world_entity, region_sides[i]); Brush_Build(region_sides[i]); } }
void Brush_SetTexture(brush_t *b,texdef_t *texdef) { face_t *f; for (f=b->brush_faces ; f ; f=f->next) f->texdef = *texdef; Brush_Build(b); }
//Timo : another version with bConvert flag //++timo since 1.7 is not compatible with earlier plugin versions, remove this one and update QERApp_BuildBrush void WINAPI QERApp_BuildBrush2 (LPVOID pv, int bConvert) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); brush_t *pBrush = g_pParentWnd->GetPlugInMgr().FindBrushHandle(pv); if (pBrush != NULL) { Brush_Build( pBrush, true, true, bConvert ); Sys_UpdateWindows(W_ALL); } }
// creates a dummy brush in the active brushes list // FIXME : is this one really USED ? void WINAPI QERApp_CreateBrush(vec3_t vMin, vec3_t vMax) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); brush_t* pBrush = Brush_Create(vMin, vMax, &g_qeglobals.d_texturewin.texdef); Entity_LinkBrush (world_entity, pBrush); Brush_Build(pBrush); Brush_AddToList (pBrush, &active_brushes); Select_Brush(pBrush); Sys_UpdateWindows(W_ALL); }
void Brush_Move (brush_t *b, vec3_t move) { int i; face_t *f; for (f=b->brush_faces ; f ; f=f->next) for (i=0 ; i<3 ; i++) Math_VectorAdd(f->planepts[i],move,f->planepts[i]); Brush_Build(b); }
void Select_FitTexture(int nHeight, int nWidth) { brush_t *b; if(selected_brushes.next == &selected_brushes && selected_face == NULL) return; for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) { Brush_FitTexture(b, nHeight, nWidth); Brush_Build(b); } if (selected_face) { Face_FitTexture(selected_face, nHeight, nWidth); Brush_Build(selected_face_brush); } Sys_UpdateWindows (W_CAMERA); }
/* ======================================================================================================================= AddProp ======================================================================================================================= */ void CEntityDlg::AddProp() { if( editEntity == NULL ) { return; } CString Key, Value; editKey.GetWindowText( Key ); editVal.GetWindowText( Value ); bool isName = ( stricmp( Key, "name" ) == 0 ); bool isModel = static_cast<bool>( ( stricmp( Key, "model" ) == 0 && Value.GetLength() > 0 ) ); bool isOrigin = ( idStr::Icmp( Key, "origin" ) == 0 ); if( multipleEntities ) { brush_t *b; for( b = selected_brushes.next; b != &selected_brushes; b = b->next ) { if( isName ) { Entity_SetName( b->owner, Value ); } else { if( !( ( isModel || isOrigin ) && ( b->owner->eclass->nShowFlags & ECLASS_WORLDSPAWN ) ) ) { SetKeyValue( b->owner, Key, Value ); } } } } else { if( isName ) { Entity_SetName( editEntity, Value ); } else { if( !( ( isModel || isOrigin ) && ( editEntity->eclass->nShowFlags & ECLASS_WORLDSPAWN ) ) ) { SetKeyValue( editEntity, Key, Value ); } } if( isModel && !( editEntity->eclass->nShowFlags & ECLASS_WORLDSPAWN ) ) { idBounds bo; idVec3 mins, maxs; selected_brushes.next->modelHandle = renderModelManager->FindModel( Value ); if( dynamic_cast<idRenderModelPrt *>( selected_brushes.next->modelHandle ) || dynamic_cast<idRenderModelLiquid *>( selected_brushes.next->modelHandle ) ) { bo.Zero(); bo.ExpandSelf( 12.0f ); } else { bo = selected_brushes.next->modelHandle->Bounds( NULL ); } VectorCopy( bo[0], mins ); VectorCopy( bo[1], maxs ); VectorAdd( mins, editEntity->origin, mins ); VectorAdd( maxs, editEntity->origin, maxs ); Brush_RebuildBrush( selected_brushes.next, mins, maxs, false ); Brush_Build( selected_brushes.next , false, false , false, true ); } } // refresh the prop listbox SetKeyValPairs(); Sys_UpdateWindows( W_ALL ); }
void Select_ApplyMatrix( bool bSnap, bool bRotation, int nAxis, float fDeg ) { brush_s* b; face_s* f; int i, j; edVec3_c temp; for ( b = selected_brushes.next ; b != &selected_brushes ; b = b->next ) { for ( f = b->brush_faces ; f ; f = f->next ) { for ( i = 0 ; i < 3 ; i++ ) { temp = f->planepts[i] - select_origin; for ( j = 0 ; j < 3 ; j++ ) f->planepts[i][j] = temp.dotProduct( select_matrix[j] ) + select_origin[j]; } if ( select_fliporder ) { // swap the points temp = f->planepts[0]; f->planepts[0] = f->planepts[2]; f->planepts[2] = temp; } } //if(b->owner->eclass->fixedsize) //{ // if (bRotation && b->owner->md3Class) // { // b->owner->vRotation[nAxis] += fDeg; // } //} Brush_Build( b, bSnap ); if ( b->patchBrush ) { //Patch_ApplyMatrix(b->nPatchID, select_origin, select_matrix); Patch_ApplyMatrix( b->pPatch, select_origin, select_matrix, bSnap ); } //if (b->terrainBrush) //{ // Terrain_ApplyMatrix(b->pTerrain, select_origin, select_matrix, bSnap); //} } }
void Select_ApplyMatrix (bool bSnap, bool bRotation, int nAxis, float fDeg) { brush_t *b; face_t *f; int i, j; vec3_t temp; for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) { for (f=b->brush_faces ; f ; f=f->next) { for (i=0 ; i<3 ; i++) { VectorSubtract (f->planepts[i], select_origin, temp); for (j=0 ; j<3 ; j++) f->planepts[i][j] = DotProduct(temp, select_matrix[j]) + select_origin[j]; } if (select_fliporder) { VectorCopy (f->planepts[0], temp); VectorCopy (f->planepts[2], f->planepts[0]); VectorCopy (temp, f->planepts[2]); } } if(b->owner->eclass->fixedsize) { if (bRotation && b->owner->md3Class) { b->owner->vRotation[nAxis] += fDeg; } } Brush_Build(b, bSnap); if (b->patchBrush) { //Patch_ApplyMatrix(b->nPatchID, select_origin, select_matrix); Patch_ApplyMatrix(b->pPatch, select_origin, select_matrix, bSnap); } if (b->terrainBrush) { Terrain_ApplyMatrix(b->pTerrain, select_origin, select_matrix, bSnap); } } }
void RotateTextures( int nAxis, float fDeg, vec3_t vOrigin ) { for ( brush_s* b = selected_brushes.next ; b != &selected_brushes ; b = b->next ) { for ( face_s* f = b->brush_faces ; f ; f = f->next ) { if ( g_qeglobals.m_bBrushPrimitMode ) RotateFaceTexture_BrushPrimit( f, nAxis, fDeg, vOrigin ); else RotateFaceTexture( f, nAxis, fDeg ); //++timo removed that call .. works fine .. ??????? // Brush_Build(b, false); } Brush_Build( b, false ); } }
/* ======================================================================================================================= ======================================================================================================================= */ void Map_BuildBrushData( void ) { brush_t *b, *next; if( active_brushes.next == NULL ) { return; } Sys_BeginWait(); // this could take a while int n = 0; for( b = active_brushes.next; b != NULL && b != &active_brushes; b = next ) { next = b->next; Brush_Build( b, true, false, false ); if( !b->brush_faces || ( g_PrefsDlg.m_bCleanTiny && CheckForTinyBrush( b, n++, g_PrefsDlg.m_fTinySize ) ) ) { Brush_Free( b ); common->Printf( "Removed degenerate brush\n" ); } } Sys_EndWait(); }
void Select_Scale(float x, float y, float z) { Select_GetMid (select_origin); for (brush_t* b=selected_brushes.next ; b != &selected_brushes ; b=b->next) { for (face_t* f=b->brush_faces ; f ; f=f->next) { for (int i=0 ; i<3 ; i++) { f->planepts[i][0] -= select_origin[0]; f->planepts[i][1] -= select_origin[1]; f->planepts[i][2] -= select_origin[2]; f->planepts[i][0] *= x; //f->planepts[i][0] = floor(f->planepts[i][0] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize; f->planepts[i][1] *= y; //f->planepts[i][1] = floor(f->planepts[i][1] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize; f->planepts[i][2] *= z; //f->planepts[i][2] = floor(f->planepts[i][2] / g_qeglobals.d_gridsize + 0.5) * g_qeglobals.d_gridsize; f->planepts[i][0] += select_origin[0]; f->planepts[i][1] += select_origin[1]; f->planepts[i][2] += select_origin[2]; } } Brush_Build(b, false); if (b->patchBrush) { vec3_t v; v[0] = x; v[1] = y; v[2] = z; //Patch_Scale(b->nPatchID, select_origin, v); Patch_Scale(b->pPatch, select_origin, v); } if (b->terrainBrush) { vec3_t v; v[0] = x; v[1] = y; v[2] = z; Terrain_Scale(b->pTerrain, select_origin, v); } } }
void Select_SetTexture (texdef_t *texdef) { brush_t *b; if (selected_face) { selected_face->texdef = *texdef; Brush_Build(selected_face_brush); } else { for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) if (!b->owner->eclass->fixedsize) Brush_SetTexture (b, texdef); } Sys_UpdateWindows (W_ALL); }
/* ============ Select_SetTexture bool bFitScale = compute scale on the plane and counteract plane->axial snapping ============ */ void Select_SetTexture (texdef_t *texdef, bool bFitScale/*=false*/, bool bNoSystemTextureOverwrite/*=false*/) { brush_t *b; if (selected_face) { SetFaceTexdef (selected_face_brush, selected_face, texdef, bFitScale, bNoSystemTextureOverwrite); Brush_Build(selected_face_brush, bFitScale); } else { for (b=selected_brushes.next ; b != &selected_brushes ; b=b->next) if (!b->owner->eclass->fixedsize) Brush_SetTexture (b, texdef, bFitScale, bNoSystemTextureOverwrite); } Sys_UpdateWindows (W_ALL); }
void CPlugInManager::CommitBrushHandleToMap(void * vp) { g_bScreenUpdates = false; for (int i = 0; i < m_BrushHandles.GetSize(); i++) { brush_t *pb = reinterpret_cast<brush_t*>(m_BrushHandles.GetAt(i)); if (pb == reinterpret_cast<brush_t*>(vp)) { m_BrushHandles.RemoveAt(i); Entity_LinkBrush (world_entity, pb); Brush_Build(pb); Brush_AddToList (pb, &active_brushes); Select_Brush(pb); } } g_bScreenUpdates = true; Sys_UpdateWindows(W_ALL); }
/* ============== NewBrushDrag ============== */ void NewBrushDrag (int x, int y) { vec3_t mins, maxs, junk; int i; float temp; brush_t *n; if (!DragDelta (x,y, junk)) return; // delete the current selection if (selected_brushes.next != &selected_brushes) Brush_Free (selected_brushes.next); XY_ToGridPoint (pressx, pressy, mins); mins[2] = g_qeglobals.d_gridsize * ((int)(g_qeglobals.d_new_brush_bottom_z/g_qeglobals.d_gridsize)); XY_ToGridPoint (x, y, maxs); maxs[2] = g_qeglobals.d_gridsize * ((int)(g_qeglobals.d_new_brush_top_z/g_qeglobals.d_gridsize)); if (maxs[2] <= mins[2]) maxs[2] = mins[2] + g_qeglobals.d_gridsize; for (i=0 ; i<3 ; i++) { if (mins[i] == maxs[i]) return; // don't create a degenerate brush if (mins[i] > maxs[i]) { temp = mins[i]; mins[i] = maxs[i]; maxs[i] = temp; } } n = Brush_Create (mins, maxs, &g_qeglobals.d_texturewin.texdef); if (!n) return; Brush_AddToList (n, &selected_brushes); Entity_LinkBrush (world_entity, n); Brush_Build( n ); // Sys_UpdateWindows (W_ALL); Sys_UpdateWindows (W_XY| W_CAMERA); }
brush_t *AddBrushForTerrain( terrainMesh_t *pm, bool bLinkToWorld ) { int j; vec3_t vMin; vec3_t vMax; brush_t *b; face_t *f; // calculate the face normals Terrain_CalcNormals( pm ); // find the farthest points in x,y,z Terrain_CalcBounds( pm, vMin, vMax ); for( j = 0; j < 3; j++ ) { if ( vMin[ j ] == vMax[ j ] ) { vMin[ j ] -= 4; vMax[ j ] += 4; } } b = Brush_Create( vMin, vMax, &pm->heightmap->tri.texdef ); for( f = b->brush_faces; f != NULL; f = f->next ) { // copy the texdef to the brush faces texdef f->texdef = pm->heightmap->tri.texdef; } // FIXME: this entire type of linkage needs to be fixed b->pTerrain = pm; b->terrainBrush = true; pm->pSymbiot = b; pm->bSelected = false; pm->bDirty = true; pm->nListID = -1; if ( bLinkToWorld ) { Brush_AddToList( b, &active_brushes ); Entity_LinkBrush( world_entity, b ); Brush_Build( b, true ); } return b; }
void CLightDlg::SaveLightInfo(const idDict *differences) { if (com_editorActive) { // used from Radiant for (brush_t *b = selected_brushes.next; b && b != &selected_brushes; b = b->next) { if ((b->owner->eclass->nShowFlags & ECLASS_LIGHT) && !b->entityModel) { if (differences) { lightInfo.ToDictFromDifferences(&b->owner->epairs, differences); } else { lightInfo.ToDict(&b->owner->epairs); } Brush_Build(b); } } } else { // used in-game idList<idEntity *> list; list.SetNum(128); int count = gameEdit->GetSelectedEntities(list.Ptr(), list.Num()); list.SetNum(count); for (int i = 0; i < count; i++) { if (differences) { gameEdit->EntityChangeSpawnArgs(list[i], differences); gameEdit->EntityUpdateChangeableSpawnArgs(list[i], NULL); } else { idDict newArgs; lightInfo.ToDict(&newArgs); gameEdit->EntityChangeSpawnArgs(list[i], &newArgs); gameEdit->EntityUpdateChangeableSpawnArgs(list[i], NULL); } gameEdit->EntityUpdateVisuals(list[i]); } } }