Пример #1
0
ProfileSection::~ProfileSection(){
	if (autoDestruct){
		ProfileEnd();
	}
}
Пример #2
0
void EntityManager::UpdatePhysics( float frametime )
{
	PROFILE_FUNCTION();

//	frametime *= 0.5f;

	Scalar total_time = frametime + m_PhysOverlapTime;

	if (total_time > 0.1f)
		total_time = 0.1f;

	// split the timestep into fixed size chunks

	int num_loops = (int) (total_time / m_PhysTimestep);
	Scalar timestep = m_PhysTimestep;

	if ( false /*m_allow_smaller_timesteps*/ )
	{
		if (num_loops == 0)
			num_loops = 1;
		timestep = total_time / num_loops;
	}

	m_PhysOverlapTime = total_time - num_loops * timestep;

//	TCPreAllocDynamicLinkList<CJL_PhysicsActor>& rActorList = m_pStage->m_pPhysicsManager->GetActorList();

//	TCPreAllocDynamicLinkList<CJL_PhysicsActor>::LinkListIterator itrActor;

	int i;
	for (i=0 ; i<num_loops ; ++i)
	{
//		m_physics_time += timestep;

		// apply gravity
/*		for( itrActor = rActorList.Begin();
			itrActor != rActorList.End();
			itrActor++ )
		{
			if( !(itrActor->GetActorFlag() & JL_ACTOR_STATIC) )
                itrActor->AddWorldForce( itrActor->GetMass() * Vector3(0,-9.8f,0) );
		}
*/

		ProfileBegin( "Entity Update (Physics)" );

		// update physics properties that are specific to each entity
		// DO NOT CONFUSE THIS WITH CCopyEntity::UpdatePhysics()
		CCopyEntity *pEntity;
		for( pEntity = m_pEntityInUse.get();
			 pEntity != NULL;
			 pEntity = pEntity->m_pNextRawPtr )
		{
			if( pEntity->GetEntityFlags() & BETYPE_COPY_PARENT_POSE )
				pEntity->CopyParentPose();

//			if( pEntity->inuse && pEntity->pPhysicsActor )
			if( pEntity->inuse && 0 < pEntity->m_vecpPhysicsActor.size() )
                pEntity->pBaseEntity->UpdatePhysics( pEntity, timestep );

			UpdateEntityAfterMoving( pEntity );

		}

		ProfileEnd( "Entity Update (Physics)" );


		{
			PROFILE_SCOPE( "Physics Simulation" );

			// handle the motions and collisions of rigid body entities
//			m_pStage->m_pPhysicsManager->Integrate( timestep );
			m_pStage->GetPhysicsScene()->Simulate( timestep );

			while( !m_pStage->GetPhysicsScene()->FetchResults( physics::SimulationStatus::RigidBodyFinished ) )
			{}
		}

		// clear forces on actors
/*		for( itrActor = rActorList.Begin();
			itrActor != rActorList.End();
			itrActor++ )
		{
			itrActor->ClearForces();
		}
*/
	}
}
Пример #3
0
int main(int argc, char **argv) {
	int retval = 0;
	char *dparams[2];
	int paramc = 0, params = -1;

	char temp[0x1000];
	int done = 0;
	char *source = NULL;
	int n = 0;

	// Acción a realizar
	int action = ACTION_NONE;

	if (argc <= 1) {
		action = ACTION_HELP;
		setparams(0);
	}

	for (n = 1; n <= argc; n++) {
		char *arg;
		arg = (n < argc) ? argv[n] : "";

		//printf("%s\n", arg);

		// Muestra la ayuda y sale
		if (strcmp(arg, "-?") == 0 || strcmp(arg, "-h") == 0 || strcmp(arg, "--help") == 0) {
			//show_help();
			action = ACTION_HELP;
			setparams(0);
		}

		// Modificadores
		{
			// Modo raw (sin cabeceras de compresión)
			if (strcmp(arg, "-r") == 0 || strcmp(arg, "-raw") == 0) { raw = 1; continue; }

			// Modo silencioso
			if (strcmp(arg, "-s") == 0) { silent = 1; fclose(stdout); continue; }
		}

		// Acciones
		{
			if (arg[0] == '-') {
				int cnt = 1;

				switch (arg[1]) {
					// Codificad
					case 'c': action = ACTION_ENCODE ; setparams(2); break;
					// Decodificia
					case 'd': action = ACTION_DECODE ; setparams(2); break;
					// Comprueba
					case 't': action = ACTION_TEST   ; setparams(1); break;
					// Crea un perfil de compresión
					case 'p': action = ACTION_PROFILE; setparams(1); break;
					// Dumpea el text_buffer inicial
					case 'b': action = ACTION_BDUMP  ; setparams(1); break;
					default:  cnt = 0; break;
				}

				if (cnt) {
					done = 0;
					modifier = (strlen(arg) >= 3) ? atoi(arg + 2) : 3;
					continue;
				}
			}
		}

		if ((n < argc) && (paramc < params)) {
			dparams[paramc++] = arg;
		}

		if (paramc >= params) {
			show_header_once();

			done = 1;
			switch (action) {
				case ACTION_ENCODE:
					if (strcmp(dparams[0], dparams[1]) != 0) {
						retval |= EncodeFile(dparams[0], dparams[1], raw, modifier);
					} else {
						fprintf(stderr, "Can't use same file for input and output\n");
						retval |= -1;
					}
				break;
				case ACTION_DECODE:
					if (strcmp(dparams[0], dparams[1]) != 0) {
						retval |= DecodeFile(dparams[0], dparams[1], raw, modifier);
					} else {
						fprintf(stderr, "Can't use same file for input and output\n");
						retval |= -1;
					}
				break;
				case ACTION_PROFILE:
					if (strlen(arg) < 0x900) {
						sprintf(temp, "%s.profile", arg);
						ProfileStart(temp);
							retval |= DecodeFile(dparams[0], NULL, raw, modifier);
						ProfileEnd();
					}
				break;
				case ACTION_BDUMP:
					DumpTextBuffer(dparams[0]);
				break;
				case ACTION_TEST:
					retval |= CheckCompression(dparams[0], modifier);
				break;
				case ACTION_HELP:
					show_help();
				break;
				default:
					if (n == argc) {
						if (paramc == params || params == 0) exit(retval);
						if (params == -1) show_help();
						fprintf(stderr, "Expected %d params, but %d given\n", params, paramc);
						exit(-1);
					}
					fprintf(stderr, "Unknown parameter '%s'\n", arg);
					exit(-1);
				break;
			}

			paramc = params = 0;
			action = ACTION_NONE;
		}
	}

	show_header_once();

	fprintf(stderr, "Expected %d params, but %d given\n", params, paramc);
	exit(-1);

	return 0;
}