示例#1
0
void CEdit::HandleMouse(int x,int y,int b)
{
    static bool bOldleft=false;
    static bool bOldright=false;

    if(!(b&MK_LBUTTON))         lbutton = false;
    else                        lbutton = true;

    if(!(b&MK_RBUTTON))         rbutton = false;
    else                        rbutton = true;


    if (lbutton && !bOldleft)   AddToUndo();    // if the mouse button was *just* pressed now
    if (rbutton && !bOldright)  AddToUndo();

    bOldleft=lbutton;
    bOldright=rbutton;

    if (PointIsInRect(x,y,rBigimage))
    {
        if (lbutton && !rbutton)
            DoLeftDownOnBigTile(
            x-rBigimage.left,
            y-rBigimage.top,
            b,nCurcolour[0]);
        else
            DoLeftUpOnBigTile(
            x-rBigimage.left,
            y-rBigimage.top,
            b);

        if (rbutton && !lbutton)
            DoLeftDownOnBigTile(
            x-rBigimage.left,
            y-rBigimage.top,
            b,nCurcolour[1]);
    }

    if (PointIsInRect(x,y,rSwatch))
    {
        if (lbutton)
            DoLeftDownOnSwatch(
            x-rSwatch.left,
            y-rSwatch.top,
            b,nCurcolour[0]);
        else
            DoLeftUpOnSwatch(
            x-rSwatch.left,
            y-rSwatch.top,
            b);

        if (rbutton)
            DoLeftDownOnSwatch(
            x-rSwatch.left,
            y-rSwatch.top,
            b,nCurcolour[1]);
    }
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CDispPaintMgr::DoPaintAdd( SpatialPaintData_t &spatialData, CMapDisp *pDisp )
{
	Vector vPaintPos, vVert;
	float flDistance2;

	int nVertCount = pDisp->GetSize();
	for ( int iVert = 0; iVert < nVertCount; iVert++ )
	{
		// Get the current vert.
		pDisp->GetVert( iVert, vVert );

		if ( IsInSphereRadius( spatialData.m_vCenter, spatialData.m_flRadius2, vVert, flDistance2 ) )
		{
			// Build the new position (paint value) and set it.
			if ( spatialData.m_uiBrushType == DISPPAINT_BRUSHTYPE_SOFT )
			{
				DoPaintOneOverR( spatialData, vVert, flDistance2, vPaintPos );
			}
			else if ( spatialData.m_uiBrushType == DISPPAINT_BRUSHTYPE_HARD )
			{
				DoPaintOne( spatialData, vVert, vPaintPos );
			}
			AddToUndo( &pDisp );
			pDisp->Paint_SetValue( iVert, vPaintPos );

			// Add data to nudge list.
			if ( spatialData.m_bNudgeInit )
			{
				NudgeAdd( pDisp, iVert );
			}
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CDispPaintMgr::DoNudgeAdd( SpatialPaintData_t &spatialData )
{
	Vector vPaintPos, vVert;
	float flDistance2;

	int nNudgeCount = m_aNudgeData.Count();
	for ( int iNudge = 0; iNudge < nNudgeCount; iNudge++ )
	{
		DispVertPair_t *pPairData = &m_aNudgeData[iNudge];

		// Get the current vert.
		CMapDisp *pDisp = EditDispMgr()->GetDisp( pPairData->m_hDisp );
		pDisp->GetVert( pPairData->m_iVert, vVert );

		if ( IsInSphereRadius( spatialData.m_vCenter, spatialData.m_flRadius2, vVert, flDistance2 ) )
		{
			// Build the new position (paint value) and set it.
			if ( spatialData.m_uiBrushType == DISPPAINT_BRUSHTYPE_SOFT )
			{
				DoPaintOneOverR( spatialData, vVert, flDistance2, vPaintPos );
			}
			else if ( spatialData.m_uiBrushType == DISPPAINT_BRUSHTYPE_HARD )
			{
				DoPaintOne( spatialData, vVert, vPaintPos );
			}
			AddToUndo( &pDisp );
			pDisp->Paint_SetValue( pPairData->m_iVert, vPaintPos );
		}
	}
}
示例#4
0
void CEdit::Redo()
{
    if (!RedoList.size())
        return;
    
    AddToUndo();
    curimage = RedoList.front();
    RedoList.pop_front();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CDispPaintMgr::DoPaintSmooth( SpatialPaintData_t &spatialData, CMapDisp *pDisp )
{
	Vector vPaintPos, vVert;
	float flDistance2;

	int nVertCount = pDisp->GetSize();
	for ( int iVert = 0; iVert < nVertCount; iVert++ )
	{
		// Get the current vert.
		pDisp->GetVert( iVert, vVert );

		if ( IsInSphereRadius( spatialData.m_vCenter, spatialData.m_flRadius2, vVert, flDistance2 ) )
		{
			// Build the new smoothed position and set it.
			if ( DoPaintSmoothOneOverExp( spatialData, vVert, vPaintPos ) )
			{
				AddToUndo( &pDisp );
				pDisp->Paint_SetValue( iVert, vPaintPos );
			}
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CDispPaintMgr::DoPaintEqual( SpatialPaintData_t &spatialData, CMapDisp *pDisp )
{
	Vector vPaintPos, vVert, vFlatVert;
	float flDistance2;

	int nVertCount = pDisp->GetSize();
	for ( int iVert = 0; iVert < nVertCount; iVert++ )
	{
		// Get the current vert.
		pDisp->GetVert( iVert, vVert );

		if ( IsInSphereRadius( spatialData.m_vCenter, spatialData.m_flRadius2, vVert, flDistance2 ) )
		{
			// Get the base vert.
			pDisp->GetFlatVert( iVert, vFlatVert );

			// Build the new position (paint value) and set it.
			DoPaintOne( spatialData, vFlatVert, vPaintPos );
			AddToUndo( &pDisp );
			pDisp->Paint_SetValue( iVert, vPaintPos );
		}
	}
}