当前位置: 首页>>代码示例>>C++>>正文


C++ idVec3::LengthSqr方法代码示例

本文整理汇总了C++中idVec3::LengthSqr方法的典型用法代码示例。如果您正苦于以下问题:C++ idVec3::LengthSqr方法的具体用法?C++ idVec3::LengthSqr怎么用?C++ idVec3::LengthSqr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在idVec3的用法示例。


在下文中一共展示了idVec3::LengthSqr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Collide

/*
================
idLiquid::Collide
Spawns a splash particle and attaches a sound to the colliding entity.
================
*/
bool idLiquid::Collide( const trace_t &collision, const idVec3 &velocity ) {
	idEntity *e = gameLocal.entities[collision.c.entityNum];
	idPhysics_Liquid *phys = static_cast<idPhysics_Liquid *>( this->GetPhysics() );
	const idDeclParticle *splash;
	const char *sName;
	float eMass;
	idVec3 splashSpot;
	float velSquare = velocity.LengthSqr();
	ProcCollisionStims( e, collision.c.id );
	eMass = e->GetPhysics()->GetMass();
	splashSpot = collision.c.point;
	if( velSquare > phys->GetMinSplashVelocity().LengthSqr() ) {
		// pick which splash particle to spawn
		// first we check the entity, if it's not defined we use
		// one defined for this liquid.
		sName = e->spawnArgs.GetString( this->smokeName.c_str() );
		if( *sName != '\0' ) {
			// load entity particle
			splash = static_cast<const idDeclParticle *>( declManager->FindType( DECL_PARTICLE, sName ) );
		} else {
			// load a liquid particle based on the mass of the splashing entity
			if( eMass < SMALL_SPLASH ) {
				splash = this->splash[0];
			} else if( eMass < MEDIUM_SPLASH ) {
				splash = this->splash[1];
			} else {
				splash = this->splash[2];
			}
		}
		// play the sound for a splash
		e->StartSound( this->soundName.c_str(), SND_CHANNEL_ANY, 0, false, NULL );
		// grayman #3413 - propagate the global sound for the splash
		idStr size = e->spawnArgs.GetString( "spr_object_size" );
		if( size.IsEmpty() ) {
			if( eMass < SMALL_SPLASH ) {
				size = "small";
			} else if( eMass < MEDIUM_SPLASH ) {
				size = "medium";
			} else {
				size = "large";
			}
		}
		idStr splashName = idStr( "splash_" ) + size;
		e->PropSoundS( NULL, splashName, 0, 0 );
	} else if( velSquare > phys->GetMinWaveVelocity().LengthSqr() ) {
		splash = this->waves;
	} else {
		// the object is moving to slow so we abort
		return true;
	}
	// spawn the particle
	gameLocal.smokeParticles->EmitSmoke( splash, gameLocal.time, gameLocal.random.RandomFloat(), splashSpot, collision.endAxis );
	return true;
}
开发者ID:revelator,项目名称:The-Darkmod-Experimental,代码行数:60,代码来源:Liquid.cpp


注:本文中的idVec3::LengthSqr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。