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


C++ Fvector::mul方法代码示例

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


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

示例1: move_along_path

void CPoltergeisMovementManager::move_along_path(CPHMovementControl *movement_control, Fvector &dest_position, float time_delta)
{
	if (!m_monster->is_hidden()) {
		inherited::move_along_path(movement_control, dest_position, time_delta);
		return;
	}

	dest_position		= m_monster->m_current_position;

	// Если нет движения по пути
	if (!enabled() || 
		path_completed() || 
		detail().path().empty() ||
		detail().completed(m_monster->m_current_position,true) || 
		(detail().curr_travel_point_index() >= detail().path().size() - 1) ||
		fis_zero(old_desirable_speed())
		)
	{
		m_speed	= 0.f;
		dest_position		= CalculateRealPosition();
		return;
	}

	if (time_delta < EPS) {
		dest_position	= CalculateRealPosition();
		return;
	}

	// Вычислить пройденную дистанцию, определить целевую позицию на маршруте, 
	//			 изменить detail().curr_travel_point_index()

	float				desirable_speed		=	old_desirable_speed();				// желаемая скорость объекта
	float				dist				=	desirable_speed * time_delta;		// пройденное расстояние в соостветствие с желаемой скоростью 
	float				desirable_dist		=	dist;

	// определить целевую точку
	Fvector				target;

	u32 prev_cur_point_index = detail().curr_travel_point_index();

	// обновить detail().curr_travel_point_index() в соответствие с текущей позицией
	while (detail().curr_travel_point_index() < detail().path().size() - 2) {

		float pos_dist_to_cur_point			= dest_position.distance_to(detail().path()[detail().curr_travel_point_index()].position);
		float pos_dist_to_next_point		= dest_position.distance_to(detail().path()[detail().curr_travel_point_index()+1].position);
		float cur_point_dist_to_next_point	= detail().path()[detail().curr_travel_point_index()].position.distance_to(detail().path()[detail().curr_travel_point_index()+1].position);

		if ((pos_dist_to_cur_point > cur_point_dist_to_next_point) && (pos_dist_to_cur_point > pos_dist_to_next_point)) {
			++detail().m_current_travel_point;			
		} else break;
	}

	target.set			(detail().path()[detail().curr_travel_point_index() + 1].position);
	// определить направление к целевой точке
	Fvector				dir_to_target;
	dir_to_target.sub	(target, dest_position);

	// дистанция до целевой точки
	float				dist_to_target = dir_to_target.magnitude();

	while (dist > dist_to_target) {
		dest_position.set	(target);

		if (detail().curr_travel_point_index() + 1 >= detail().path().size())	break;
		else {
			dist			-= dist_to_target;
			++detail().m_current_travel_point;
			if ((detail().curr_travel_point_index()+1) >= detail().path().size())
				break;
			target.set			(detail().path()[detail().curr_travel_point_index() + 1].position);
			dir_to_target.sub	(target, dest_position);
			dist_to_target		= dir_to_target.magnitude();
		}
	}

	if (prev_cur_point_index != detail().curr_travel_point_index()) on_travel_point_change(prev_cur_point_index);

	if (dist_to_target < EPS_L) {
		detail().m_current_travel_point = detail().path().size() - 1;
		m_speed			= 0.f;
		dest_position	= CalculateRealPosition();
		return;
	}

	// установить позицию
	Fvector				motion;
	motion.mul			(dir_to_target, dist / dist_to_target);
	dest_position.add	(motion);

	// установить скорость
	float	real_motion	= motion.magnitude() + desirable_dist - dist;
	float	real_speed	= real_motion / time_delta;

	m_speed				= 0.5f * desirable_speed + 0.5f * real_speed;

	// Обновить позицию
	m_monster->m_current_position	= dest_position;
	m_monster->Position()			= CalculateRealPosition();
	dest_position					= m_monster->Position();
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:100,代码来源:poltergeist_movement.cpp

示例2: PlayHitMotion

void character_hit_animation_controller::PlayHitMotion( const Fvector &dir, const Fvector &bone_pos, u16 bi, CEntityAlive &ea )const
{
	IRenderVisual *pV = ea.Visual( );
	IKinematicsAnimated* CA = smart_cast<IKinematicsAnimated*>( pV );
	IKinematics* K = smart_cast<IKinematics*>( pV );
	
	//play_cycle(CA,all_shift_down,1,block_times[6],1) ;
	if( !( K->LL_BoneCount( ) > bi ) )
		return;

	Fvector dr = dir;
	Fmatrix m;
	GetBaseMatrix( m, ea );

#ifdef DEBUG
	if( ph_dbg_draw_mask1.test( phDbgHitAnims ) )
	{
		DBG_OpenCashedDraw();
		DBG_DrawLine( m.c, Fvector( ).sub( m.c, Fvector( ).mul( dir, 1.5 ) ), D3DCOLOR_XRGB( 255, 0, 255 ) );
		DBG_ClosedCashedDraw( 1000 );
	}
#endif

	m.invert( );
	m.transform_dir( dr );
//
	Fvector hit_point;
	K->LL_GetTransform( bi ).transform_tiny( hit_point, bone_pos );
	ea.XFORM( ).transform_tiny( hit_point );
	m.transform_tiny( hit_point );
	Fvector torqu;		
	torqu.crossproduct( dr, hit_point );
	hit_point.x = 0;


	float rotational_ammount = hit_point.magnitude( ) * g_params.power_factor * g_params.rotational_power_factor;//_abs(torqu.x)
	
	if( torqu.x < 0 )
		play_cycle( CA, hit_downr, 3, block_blends[7], 1 ) ;
	else
		play_cycle( CA, hit_downl, 3, block_blends[6], 1 ) ;

	if( !IsEffected( bi, *K ) )
		return;
	if( torqu.x<0 )
		play_cycle( CA, turn_right, 2, block_blends[4], rotational_ammount ) ;
	else
		play_cycle( CA, turn_left, 2, block_blends[5], rotational_ammount ) ;

	//CA->LL_SetChannelFactor(3,rotational_ammount);

	dr.x = 0;
	dr.normalize_safe();


	dr.mul(g_params.power_factor);
	if( dr.y > g_params.side_sensitivity_threshold )
		play_cycle( CA, rthit_motion, 2, block_blends[0], _abs( dr.y ) ) ;
	else if( dr.y < -g_params.side_sensitivity_threshold )
		play_cycle( CA, lthit_motion, 2, block_blends[1], _abs( dr.y ) ) ;

	if( dr.z<0.f )
		play_cycle( CA, fvhit_motion, 2, block_blends[2], _abs(dr.z) ) ;
	else
		play_cycle( CA, bkhit_motion, 2, block_blends[3], _abs( dr.z ) ) ;

	CA->LL_SetChannelFactor( 2, g_params.anim_channel_factor );


}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:70,代码来源:character_hit_animations.cpp

示例3: Update


//.........这里部分代码省略.........
			shoulder.sub(body_to_joint,body_to_first);
			if(b_body_second)
			{

				Fvector joint_force;
				joint_force.set(*(const Fvector*)feedback->f2);
				first_part_force.add(joint_force);
				Fvector torque;
				torque.crossproduct(shoulder,joint_force);
				first_part_torque.add(torque);
			}
			else
			{
				Fvector joint_force;
				joint_force.set(*(const Fvector*)feedback->f1);
				first_part_force.add(joint_force);
				Fvector torque;
				torque.crossproduct(shoulder,joint_force);
				first_part_torque.add(torque);
			}
		}

	}

	PH_IMPACT_I i_i=impacts.begin(),i_e=impacts.end();
	for(;i_i!=i_e;i_i++)
	{
		u16 geom = i_i->geom;

		if((geom>=m_start_geom_num&&geom<m_end_geom_num))
		{
			Fvector force;
			force.set(i_i->force);
			force.mul(ph_console::phRigidBreakWeaponFactor);
			Fvector second_to_point;
			second_to_point.sub(body_to_second,i_i->point);
			//force.mul(30.f);
			second_part_force.add(force);
			Fvector torque;
			torque.crossproduct(second_to_point,force);
			second_part_torque.add(torque);
		}
		else
		{
			Fvector force;
			force.set(i_i->force);
			Fvector first_to_point;
			first_to_point.sub(body_to_first,i_i->point);
			//force.mul(4.f);
			first_part_force.add(force);
			Fvector torque;
			torque.crossproduct(first_to_point,force);
			second_part_torque.add(torque);
		}
	}
	Fvector gravity_force;
	gravity_force.set(0.f,-ph_world->Gravity()*m_firstM.mass,0.f);
	first_part_force.add(gravity_force);
	second_part_force.add(gravity_force);
	dMatrix3 glI1,glI2,glInvI,tmp;	

	// compute inertia tensors in global frame
	dMULTIPLY2_333 (tmp,body->invI,body->R);
	dMULTIPLY0_333 (glInvI,body->R,tmp);

	dMULTIPLY2_333 (tmp,m_firstM.I,body->R);
开发者ID:AntonioModer,项目名称:xray-16,代码行数:67,代码来源:PHFracture.cpp

示例4: g_cl_CheckControls


//.........这里部分代码省略.........
		if(!(mstate_real&(mcFwd|mcLStrafe|mcRStrafe))||mstate_real&(mcCrouch|mcClimb)|| !isActorAccelerated(mstate_wf, IsZoomAimingMode()))
		{
			mstate_real&=~mcSprint;
			mstate_wishful&=~mcSprint;
		}
				
		// check player move state
		if(mstate_real&mcAnyMove)
		{
			BOOL	bAccelerated		= isActorAccelerated(mstate_real, IsZoomAimingMode())&&CanAccelerate();

			// correct "mstate_real" if opposite keys pressed
			if (_abs(vControlAccel.z)<EPS)	mstate_real &= ~(mcFwd+mcBack		);
			if (_abs(vControlAccel.x)<EPS)	mstate_real &= ~(mcLStrafe+mcRStrafe);

			// normalize and analyze crouch and run
			float	scale			= vControlAccel.magnitude();
			if(scale>EPS)	
			{
				scale	=	m_fWalkAccel/scale;
				if (bAccelerated)
					if (mstate_real&mcBack)
						scale *= m_fRunBackFactor;
					else
						scale *= m_fRunFactor;
				else
					if (mstate_real&mcBack)
						scale *= m_fWalkBackFactor;



				if (mstate_real&mcCrouch)	scale *= m_fCrouchFactor;
				if (mstate_real&mcClimb)	scale *= m_fClimbFactor;
				if (mstate_real&mcSprint)	scale *= m_fSprintFactor;

				if (mstate_real&(mcLStrafe|mcRStrafe) && !(mstate_real&mcCrouch))
				{
					if (bAccelerated)
						scale *= m_fRun_StrafeFactor;
					else
						scale *= m_fWalk_StrafeFactor;
				}

				vControlAccel.mul			(scale);
				cam_eff_factor				= scale;
			}//scale>EPS
		}//(mstate_real&mcAnyMove)
	}//peOnGround || peAtWall

	if(IsGameTypeSingle() && cam_eff_factor>EPS)
	{
	LPCSTR state_anm				= NULL;

	if(mstate_real&mcSprint && !(mstate_old&mcSprint) )
		state_anm					= "sprint";
	else
	if(mstate_real&mcLStrafe && !(mstate_old&mcLStrafe) )
		state_anm					= "strafe_left";
	else
	if(mstate_real&mcRStrafe && !(mstate_old&mcRStrafe) )
		state_anm					= "strafe_right";
	else
	if(mstate_real&mcFwd && !(mstate_old&mcFwd) )
		state_anm					= "move_fwd";
	else
	if(mstate_real&mcBack && !(mstate_old&mcBack) )
		state_anm					= "move_back";

		if(state_anm)
		{ //play moving cam effect
			CActor*	control_entity		= static_cast_checked<CActor*>(Level().CurrentControlEntity());
			R_ASSERT2					(control_entity, "current control entity is NULL");
			CEffectorCam* ec			= control_entity->Cameras().GetCamEffector(eCEActorMoving);
			if(NULL==ec)
			{
				string_path			eff_name;
				xr_sprintf			(eff_name, sizeof(eff_name), "%s.anm", state_anm);
				string_path			ce_path;
				string_path			anm_name;
				strconcat			(sizeof(anm_name), anm_name, "camera_effects\\actor_move\\", eff_name);
				if (FS.exist( ce_path, "$game_anims$", anm_name))
				{
					CAnimatorCamLerpEffectorConst* e		= xr_new<CAnimatorCamLerpEffectorConst>();
					float max_scale				= 70.0f;
					float factor				= cam_eff_factor/max_scale;
					e->SetFactor				(factor);
					e->SetType					(eCEActorMoving);
					e->SetHudAffect				(false);
					e->SetCyclic				(false);
					e->Start					(anm_name);
					control_entity->Cameras().AddCamEffector(e);
				}
			}
		}
	}
	//transform local dir to world dir
	Fmatrix				mOrient;
	mOrient.rotateY		(-r_model_yaw);
	mOrient.transform_dir(vControlAccel);
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:101,代码来源:Actor_Movement.cpp

示例5: msimulator_CollideWithWorld

//-----------------------------------------------------------------------------
// Name: collideWithWorld()
// Desc: Recursive part of the collision response. This function is the
//       one who actually calls the collision check on the meshes
//-----------------------------------------------------------------------------
Fvector msimulator_CollideWithWorld(SCollisionData& cl, Fvector position, Fvector velocity, WORD cnt) 
{
	// 
	msimulator_ResolveStuck(cl,position);

	// do we need to worry ?
//	if (fsimilar(position.x,target.x,EPS_L)&&fsimilar(position.z,target.z,EPS_L))
	if (velocity.magnitude()<EPS_L)
	{
		cl.vVelocity.set(0,0,0);
		return position;
	}
	if (cnt>psCollideActDepth)				return cl.vLastSafePosition;
	
	Fvector ret_pos;
	Fvector destinationPoint;
	destinationPoint.add(position,velocity);
	
	// reset the collision package we send to the mesh 
	cl.vVelocity.set	(velocity);
	cl.vSourcePoint.set	(position);
	cl.bFoundCollision	= FALSE;
	cl.bStuck			= FALSE;
	cl.fNearestDistance	= -1;	
	
	// Check collision
	msimulator_CheckCollision	(cl);	
	
	// check return value here, and possibly call recursively 	
	if (cl.bFoundCollision == FALSE  && !cl.bStuck)
	{ 
		// if no collision move very close to the desired destination. 
		float l = velocity.magnitude();
		Fvector V;
		V.mul(velocity,(l-cl_epsilon)/l); 
		
		// return the final position
		ret_pos.add(position,V);
		
		// update the last safe position for future error recovery	
		cl.vLastSafePosition.set(ret_pos);
		return ret_pos;
	}else{ 
		// There was a collision
		// OK, first task is to move close to where we hit something :
		Fvector newSourcePoint;
		
		// If we are stuck, we just back up to last safe position
		if (cl.bStuck){
			return cl.vLastSafePosition;
		}

		// only update if we are not already very close
		if (cl.fNearestDistance >= cl_epsilon) {
			Fvector V;
			V.set(velocity);
			V.set_length(cl.fNearestDistance-cl_epsilon);
			newSourcePoint.add(cl.vSourcePoint,V);
		}else {
			newSourcePoint.set(cl.vSourcePoint);
		}
		
		// Now we must calculate the sliding plane
		Fvector slidePlaneOrigin; slidePlaneOrigin.set(cl.vNearestPolygonIntersectionPoint);
		Fvector slidePlaneNormal; slidePlaneNormal.sub(newSourcePoint,cl.vNearestPolygonIntersectionPoint);
		
		// We now project the destination point onto the sliding plane
		float l = intersectRayPlane(destinationPoint, slidePlaneNormal, slidePlaneOrigin, slidePlaneNormal); 

		// We can now calculate a _new destination point on the sliding plane
		Fvector newDestinationPoint;
		newDestinationPoint.mad(destinationPoint,slidePlaneNormal,l);
		
		// Generate the slide xr_vector, which will become our _new velocity xr_vector
		// for the next iteration
		Fvector newVelocityVector;
		newVelocityVector.sub(newDestinationPoint, cl.vNearestPolygonIntersectionPoint);
		
		// now we recursively call the function with the _new position and velocity 
		cl.vLastSafePosition.set(position);
		return msimulator_CollideWithWorld(cl, newSourcePoint, newVelocityVector,cnt+1); 
	}
}
开发者ID:NeoAnomaly,项目名称:xray,代码行数:88,代码来源:motion_simulator.cpp

示例6: msimulator_Simulate

void msimulator_Simulate( Fvector& result, Fvector& start, Fvector& end, float _radius, float _height)
{
	SCollisionData	cl_data;
	float			half_height	= _height/2;

	// Calc BB
	Fbox			b1,b2,bb;
	create_bb		(b1,start,	_radius,_height);
	create_bb		(b2,end,	_radius,_height);
	bb.merge		(b1,b2);
	bb.grow			(0.05f);

	// Collision query
	Fvector			bbC,bbD;
	bb.get_CD		(bbC,bbD);
	XRC.box_options	(0);
	XRC.box_query	(&Level,bbC,bbD);
	
	// XForm everything to ellipsoid space
	Fvector			xf;
	xf.set			(1/_radius,1/half_height,1/_radius);

	Fvector			Lposition;
	Lposition.set	(start);
	Lposition.y		+= half_height;
	Lposition.mul	(xf);

	Fvector			target;
	target.set		(end);
	target.y		+= half_height;
	target.mul		(xf);

	Fvector			Lvelocity;
	Lvelocity.sub	(end,start);
	Lvelocity.mul	(xf);

	cl_data.vLastSafePosition.set	(Lposition);

	// Get the data for the triangles in question and scale to ellipsoid space
	int tri_count			= XRC.r_count();
	clContactedT.resize		(tri_count);
	if (tri_count) {
		Fvector vel_dir;
		vel_dir.normalize_safe	(Lvelocity);
		for (int i_t=0; i_t<tri_count; i_t++){
			cl_tri& T			= clContactedT[i_t];
			CDB::RESULT&		rp = XRC.r_begin()[i_t];
//			CDB::TRI&	O		= 
				*(Level.get_tris()+rp.id);

			T.p[0].mul			(rp.verts[0],xf);
			T.p[1].mul			(rp.verts[1],xf);
			T.p[2].mul			(rp.verts[2],xf);
			T.N.mknormal		(T.p[0],T.p[1],T.p[2]);
			
			T.d = -T.N.dotproduct(T.p[0]);
			T.e10.sub(T.p[1],T.p[0]); T.e10s = T.e10.magnitude(); T.e10.div(T.e10s);
			T.e21.sub(T.p[2],T.p[1]); T.e21s = T.e21.magnitude(); T.e21.div(T.e21s);
			T.e02.sub(T.p[0],T.p[2]); T.e02s = T.e02.magnitude(); T.e02.div(T.e02s);
		}
	}

	// call the recursive collision response function	
	Fvector POS;

	for (int i=0; i<3; i++) {
		POS.set(msimulator_CollideWithWorld(cl_data, Lposition, Lvelocity, 0));
		if (fsimilar(POS.x,target.x)&&fsimilar(POS.z,target.z)) break;

		Lposition.set	(POS);
		Lvelocity.sub	(target,POS);
		Lvelocity.y		= 0;
	}

	result.div(POS,xf);
	result.y-=half_height;
}
开发者ID:NeoAnomaly,项目名称:xray,代码行数:77,代码来源:motion_simulator.cpp

示例7: GetRayExplosionSourcePos

void CExplosive::GetRayExplosionSourcePos(Fvector &pos)
{
	pos.set						(m_vExplodeSize);pos.mul(0.5f);
	pos.random_point			(pos);
	pos.add						(m_vExplodePos);
}
开发者ID:AntonioModer,项目名称:xray-16,代码行数:6,代码来源:Explosive.cpp

示例8: g_cl_CheckControls


//.........这里部分代码省略.........
		u32 move	= mcAnyMove|mcAccel;

		if (((mstate_real&mcCrouch)))
		{
			if (!isActorAccelerated(mstate_real, IsZoomAimingMode()) && isActorAccelerated(mstate_wf, IsZoomAimingMode()))
			{
				character_physics_support()->movement()->EnableCharacter();
				if(!character_physics_support()->movement()->ActivateBoxDynamic(1))move	&=~mcAccel;
			}

			if (isActorAccelerated(mstate_real, IsZoomAimingMode()) && !isActorAccelerated(mstate_wf, IsZoomAimingMode()))
			{
				character_physics_support()->movement()->EnableCharacter();
				if(character_physics_support()->movement()->ActivateBoxDynamic(2))mstate_real	&=~mcAccel;
			}
		}

		if ((mstate_wf&mcSprint) && !CanSprint())
		{
			mstate_wf				&= ~mcSprint;
		}

		mstate_real &= (~move);
		mstate_real |= (mstate_wf & move);

		if(mstate_wf&mcSprint)
			mstate_real|=mcSprint;
		else
			mstate_real&=~mcSprint;
		if(!(mstate_real&(mcFwd|mcLStrafe|mcRStrafe))||mstate_real&(mcCrouch|mcClimb)|| !isActorAccelerated(mstate_wf, IsZoomAimingMode()))
		{
			mstate_real&=~mcSprint;
			mstate_wishful&=~mcSprint;
		}
				
		// check player move state
		if (mstate_real&mcAnyMove)
		{
			BOOL	bAccelerated		= isActorAccelerated(mstate_real, IsZoomAimingMode())&&CanAccelerate();



			// correct "mstate_real" if opposite keys pressed
			if (_abs(vControlAccel.z)<EPS)	mstate_real &= ~(mcFwd+mcBack		);
			if (_abs(vControlAccel.x)<EPS)	mstate_real &= ~(mcLStrafe+mcRStrafe);

			// normalize and analyze crouch and run
			float	scale				= vControlAccel.magnitude();
			if (scale>EPS)	{
				scale	=	m_fWalkAccel/scale;
				if (bAccelerated)
					if (mstate_real&mcBack)
						scale *= m_fRunBackFactor;
					else
						scale *= m_fRunFactor;
				else
					if (mstate_real&mcBack)
						scale *= m_fWalkBackFactor;



				if (mstate_real&mcCrouch)	scale *= m_fCrouchFactor;
				if (mstate_real&mcClimb)	scale *= m_fClimbFactor;
				if (mstate_real&mcSprint)	scale *= m_fSprintFactor;

				if (mstate_real&(mcLStrafe|mcRStrafe) && !(mstate_real&mcCrouch))
				{
					if (bAccelerated)
						scale *= m_fRun_StrafeFactor;
					else
						scale *= m_fWalk_StrafeFactor;
				}

				vControlAccel.mul			(scale);
			}else{
				//				mstate_real	&= ~mcAnyMove;
			}
		}		
	}else{
		//		mstate_real			&=~ mcAnyMove;
	}

	//-------------------------------------------------------------------------------	
	

	//transform local dir to world dir
	Fmatrix				mOrient;
	mOrient.rotateY		(-r_model_yaw);
	mOrient.transform_dir(vControlAccel);
	//XFORM().transform_dir(vControlAccel);

	/*
	if(mstate_real&mcClimb&&mstate_real&mcAnyMove&&
	inventory().ActiveItem()&&inventory().ActiveItem()->HandDependence()==hd2Hand)
	{
		//inventory().ActiveItem()->Deactivate();
		inventory().Activate(NO_ACTIVE_SLOT);
	}
*/
}
开发者ID:OLR-xray,项目名称:OLR-3.0,代码行数:101,代码来源:Actor_Movement.cpp

示例9:

void CCharacterPhysicsSupport::ActivateShell			(CObject* who)
{
	DestroyIKController();
	if(!m_physics_skeleton)CreateSkeleton(m_physics_skeleton);
	if(m_eType==etActor)
	{
		CActor* A=smart_cast<CActor*>(&m_EntityAlife);
		R_ASSERT2(A,"not an actor has actor type");
		if(A->Holder()) return;
		if(m_eState==esRemoved)return;
	}
	CKinematics* K=smart_cast<CKinematics*>(m_EntityAlife.Visual());
//////////////////////this needs to evaluate object box//////////////////////////////////////////////////////
	for(u16 I=K->LL_BoneCount()-1;I!=u16(-1);--I)K->LL_GetBoneInstance(I).reset_callback();

	K->CalculateBones_Invalidate();
	K->CalculateBones	();
////////////////////////////////////////////////////////////////////////////
	if(m_pPhysicsShell) return;
	Fvector velocity;
	m_PhysicMovementControl->GetCharacterVelocity		(velocity);
	velocity.mul(1.3f);
	Fvector dp,start;start.set(m_EntityAlife.Position());
	if(!m_PhysicMovementControl->CharacterExist())
		dp.set(m_EntityAlife.Position());
	else m_PhysicMovementControl->GetDeathPosition(dp);
	m_PhysicMovementControl->DestroyCharacter();
	CollisionCorrectObjPos(dp);

	R_ASSERT2(m_physics_skeleton,"No skeleton created!!");
	m_pPhysicsShell=m_physics_skeleton;
	m_physics_skeleton=NULL;
	m_pPhysicsShell->set_Kinematics(K);
	m_pPhysicsShell->RunSimulation();
	m_pPhysicsShell->mXFORM.set(mXFORM);
	m_pPhysicsShell->SetCallbacks(m_pPhysicsShell->GetBonesCallback());
	if(!smart_cast<CCustomZone*>(who))
	{
		velocity.mul(1.25f*m_after_death_velocity_factor);
	}
	if(!DoCharacterShellCollide())
	{
		m_pPhysicsShell->DisableCharacterCollision();
	}
	m_pPhysicsShell->set_LinearVel(velocity);
	K->CalculateBones_Invalidate();
	K->CalculateBones	();
	m_flags.set(fl_death_anim_on,FALSE);
	m_eState=esDead;
	m_flags.set(fl_skeleton_in_shell,TRUE);
	
	if(IsGameTypeSingle())
	{
		m_pPhysicsShell->SetPrefereExactIntegration	();//use exact integration for ragdolls in single
		m_pPhysicsShell->SetRemoveCharacterCollLADisable();
	}
	else
	{
		m_pPhysicsShell->SetIgnoreDynamic();
	}
	m_pPhysicsShell->SetIgnoreSmall();
	FlyTo(Fvector().sub(start,m_EntityAlife.Position()));
	m_pPhysicsShell->GetGlobalTransformDynamic(&mXFORM);
	m_pPhysicsShell->add_ObjectContactCallback(OnCharacterContactInDeath);
	m_pPhysicsShell->set_CallbackData((void*)this);
}
开发者ID:OLR-xray,项目名称:XRay-NEW,代码行数:66,代码来源:CharacterPhysicsSupport.cpp


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