Пример #1
0
CDisableRangeChecks::CDisableRangeChecks()
{
	if ( !ThreadInMainThread() )
		return;
	g_nDisables++;
	g_bDoRangeChecks = false;
}
Пример #2
0
CDisableRangeChecks::~CDisableRangeChecks()
{
	if ( !ThreadInMainThread() )
		return;
	Assert( g_nDisables > 0 );
	--g_nDisables;
	if ( g_nDisables == 0 )
	{
		g_bDoRangeChecks = true;
	}
}
Пример #3
0
void CPoseDebuggerImpl::AccumulatePose( const CStudioHdr *pStudioHdr, CIKContext *pIKContext,
									    Vector pos[], Quaternion q[], int sequence, float cycle,
										const float poseParameter[], int boneMask,
										float flWeight, float flTime )
{
//	virtualmodel_t const *pVMdl = pStudioHdr->GetVirtualModel();
// 	if ( !pVMdl )
// 		return;

	if ( !ThreadInMainThread() )
	{
		return;
	}

	studiohdr_t const *pRMdl = pStudioHdr->GetRenderHdr();
	if ( !pRMdl ||
		 !pRMdl->numincludemodels )
		return;

	MapModel::IndexType_t idxMapModel = m_mapModel.Find( pStudioHdr );
	if ( idxMapModel == m_mapModel.InvalidIndex() )
		return;

	ModelPoseDebugInfo &mpi = m_mapModel.Element( idxMapModel );
	if ( !IsModelShown( mpi.m_iEntNum ) )
		return;

	ModelPoseDebugInfo *pMpiOld = NULL;
	MapModel::IndexType_t idxMapModelOld = m_mapModelOld.Find( pStudioHdr );
	if ( idxMapModelOld != m_mapModelOld.InvalidIndex() )
	{
		pMpiOld = &m_mapModelOld.Element( idxMapModelOld );
	}


	//
	// Actual processing
	//

	mstudioseqdesc_t	&seqdesc = ((CStudioHdr *)pStudioHdr)->pSeqdesc( sequence );

	if ( sequence >= pStudioHdr->GetNumSeq() )
	{
		sequence = 0;
		seqdesc = ((CStudioHdr *)pStudioHdr)->pSeqdesc( sequence );
	}

	enum
	{
		widthActivity	= 35,
		widthLayer		= 35,
		widthIks		= 60,
		widthPercent	= 6,
	};

	// Prepare the text
	char chBuffer[256];
	ModelPoseDebugInfo::InfoText txt;
	int numLines = 0;
	
	txt.m_iActivity = seqdesc.activity;
	sprintf( txt.m_chActivity, "%s", seqdesc.pszActivityName() );
	sprintf( txt.m_chLabel, "%s", seqdesc.pszLabel() );

	if ( !txt.m_chActivity[0] )
	{
		// Try to find the last seen activity and re-use it
		for ( int iLast = mpi.m_arrTxt.Count(); iLast --> 0; )
		{
			ModelPoseDebugInfo::InfoText &lastSeenTxt = mpi.m_arrTxt[iLast];
			if ( lastSeenTxt.m_uiFlags & ModelPoseDebugInfo::F_SEEN_THIS_FRAME &&
				 lastSeenTxt.m_chActivity[0] )
			{
				sprintf( txt.m_chActivity, "%s", lastSeenTxt.m_chActivity );
				break;
			}
		}
	}

	// The layer information
	ModelPoseDebugInfo::InfoText *pOldTxt = pMpiOld ? pMpiOld->LookupInfoText( &txt ) : NULL;
	sprintf( txt.m_chTextLines[numLines],
		"%-*s  %-*s  %*.2f  %*.1f/%-*d  %*.0f%% ",
		widthActivity,
		seqdesc.pszActivityName(),
		widthLayer,
		seqdesc.pszLabel(),
		7,
		pOldTxt ? pOldTxt->m_flTimeAlive : 0.f,
		5,
		cycle * ( ((CStudioHdr *)pStudioHdr)->pAnimdesc( seqdesc.anim( 0, 0 ) ).numframes - 1 ),
		3,
		((CStudioHdr *)pStudioHdr)->pAnimdesc( seqdesc.anim( 0, 0 ) ).numframes,
		widthPercent,
		flWeight * 100.0f
		);
	++ numLines;

	if ( seqdesc.numiklocks )
	{
		sprintf( chBuffer,
			"iklocks : %-2d : ",
			seqdesc.numiklocks );

		for ( int k = 0; k < seqdesc.numiklocks; ++ k )
		{
			mstudioiklock_t *plock = seqdesc.pIKLock( k );
			mstudioikchain_t *pchain = pStudioHdr->pIKChain( plock->chain );

			sprintf( chBuffer + strlen( chBuffer ), "%s ", pchain->pszName() );
			// plock->flPosWeight;
			// plock->flLocalQWeight;
		}

		sprintf( txt.m_chTextLines[numLines],
			"%-*s",
			widthIks,
			chBuffer
			);
		++ numLines;
	}

	if ( seqdesc.numikrules )
	{
		sprintf( chBuffer, "ikrules : %-2d",
			seqdesc.numikrules );

		sprintf( txt.m_chTextLines[numLines],
			"%-*s",
			widthIks,
			chBuffer
			);
		++ numLines;
	}


	// Now add the accumulated text into the container
	mpi.AddInfoText( &txt, pMpiOld );
	mpi.PrintPendingInfoText( m_nPosPrint );
}
Пример #4
0
void CPoseDebuggerImpl::StartBlending( IClientNetworkable *pEntity, const CStudioHdr *pStudioHdr )
{
//	virtualmodel_t const *pVMdl = pStudioHdr->GetVirtualModel();
// 	if ( !pVMdl )
// 		return;

	if ( !ThreadInMainThread() )
	{
		ExecuteOnce( "Turn of threading when using pose debugger\n" );
		return;
	}

	// If we are starting a new model then finalize the previous one
	if ( pStudioHdr != m_pLastModel && m_pLastModel )
	{
		MapModel::IndexType_t idx = m_mapModel.Find( m_pLastModel );
		if ( idx != m_mapModel.InvalidIndex() )
		{
			ModelPoseDebugInfo &mpi = m_mapModel.Element( idx );
			ModelPoseDebugInfo *pMpiOld = NULL;
			MapModel::IndexType_t idxMapModelOld = m_mapModelOld.Find( m_pLastModel );
			if ( idxMapModelOld != m_mapModelOld.InvalidIndex() )
			{
				pMpiOld = &m_mapModelOld.Element( idxMapModelOld );
			}
			mpi.AddInfoText( NULL, pMpiOld );
			mpi.PrintPendingInfoText( m_nPosPrint );
		}
	}
	m_pLastModel = pStudioHdr;

	// Go ahead with the new model
	studiohdr_t const *pRMdl = pStudioHdr->GetRenderHdr();
	if ( !pRMdl ||
		 !pRMdl->numincludemodels )
		return;

	// Entity number
	int iEntNum = pEntity->entindex();
	if ( !IsModelShown( iEntNum ) )
		return;

	// Check if we saw the model
	if ( m_mapModel.Find( pStudioHdr ) != m_mapModel.InvalidIndex() )
	{
		// Initialize the printing position
		m_nPosPrint = 9;

		// Swap the maps
		m_mapModelOld.RemoveAll();
		m_mapModelOld.Swap( m_mapModel );

		// Zero out the text on the old map
		for ( int k = m_mapModelOld.FirstInorder();
			  k != m_mapModelOld.InvalidIndex();
			  k = m_mapModelOld.NextInorder( k ) )
		{
			ModelPoseDebugInfo &mpi = m_mapModelOld[k];
			mpi.m_iCurrentText = 0;
		}
	}
	else
	{
		// Next model
		m_nPosPrint += 3;
	}

	ModelPoseDebugInfo mpi;
	mpi.m_iEntNum = iEntNum;
	m_mapModel.Insert( pStudioHdr, mpi );

	con_nprint_s nxPrn = { 0 };
	nxPrn.index = m_nPosPrint;
	nxPrn.time_to_live = -1;
	nxPrn.color[0] = 0.9f, nxPrn.color[1] = 1.0f, nxPrn.color[2] = 0.9f;
	nxPrn.fixed_width_font = false;

	engine->Con_NXPrintf( &nxPrn, "[ %2d  ]    Model: %s", iEntNum, pRMdl->pszName() );
	m_nPosPrint += 3;
}
Пример #5
0
DBG_INTERFACE bool DoNewAssertDialog( const tchar *pFilename, int line, const tchar *pExpression )
{
	LOCAL_THREAD_LOCK();

	if ( AreAssertsDisabled() )
		return false;

	// If they have the old mode enabled (always break immediately), then just break right into
	// the debugger like we used to do.
	if ( IsDebugBreakEnabled() )
		return true;

	// Have ALL Asserts been disabled?
	if ( !g_bAssertsEnabled )
		return false;

	// Has this specific Assert been disabled?
	if ( !AreAssertsEnabledInFileLine( pFilename, line ) )
		return false;

	// Now create the dialog.
	g_Info.m_pFilename = pFilename;
	g_Info.m_iLine = line;
	g_Info.m_pExpression = pExpression;

	g_bBreak = false;

#if defined( _X360 )

	char cmdString[XBX_MAX_RCMDLENGTH];

	// Before calling VXConsole, init the global variable that receives the result
	g_VXConsoleAssertReturnValue = -1;

	// Message VXConsole to pop up a PC-side Assert dialog
	_snprintf( cmdString, sizeof(cmdString), "Assert() 0x%.8x File: %s\tLine: %d\t%s",
				&g_VXConsoleAssertReturnValue, pFilename, line, pExpression );
	XBX_SendRemoteCommand( cmdString, false );

	// We sent a synchronous message, so g_xbx_dbgVXConsoleAssertReturnValue should have been overwritten by now
	if ( g_VXConsoleAssertReturnValue == -1 )
	{
		// VXConsole isn't connected/running - default to the old behaviour (break)
		g_bBreak = true;
	}
	else
	{
		// Respond to what the user selected
		switch( g_VXConsoleAssertReturnValue )
		{
		case ASSERT_ACTION_IGNORE_FILE:
			IgnoreAssertsInCurrentFile();
			break;
		case ASSERT_ACTION_IGNORE_THIS:
			// Ignore this Assert once
			break;
		case ASSERT_ACTION_BREAK:
			// Break on this Assert
			g_bBreak = true;
			break;
		case ASSERT_ACTION_IGNORE_ALL:
			// Ignore all Asserts from now on
			g_bAssertsEnabled = false;
			break;
		case ASSERT_ACTION_IGNORE_ALWAYS:
			// Ignore this Assert from now on
			IgnoreAssertsNearby( 0 );
			break;
		case ASSERT_ACTION_OTHER:
		default:
			// Error... just break
			XBX_Error( "DoNewAssertDialog: invalid Assert response returned from VXConsole - breaking to debugger" );
			g_bBreak = true;
			break;
		}
	}

#elif defined( _WIN32 )

	if ( !ThreadInMainThread() )
	{
		int result = MessageBox( NULL,  pExpression, "Assertion Failed", MB_SYSTEMMODAL | MB_CANCELTRYCONTINUE );

		if ( result == IDCANCEL )
		{
			IgnoreAssertsNearby( 0 );
		}
		else if ( result == IDCONTINUE )
		{
			g_bBreak = true;
		}
	}
	else
	{
		HWND hParentWindow = FindLikelyParentWindow();

		DialogBox( g_hTier0Instance, MAKEINTRESOURCE( IDD_ASSERT_DIALOG ), hParentWindow, AssertDialogProc );
	}

#elif _LINUX

	fprintf(stderr, "%s %i %s", pFilename, line, pExpression);

#endif

	return g_bBreak;
}