Example #1
0
void CCharacterPhysicsSupport::in_NetDestroy( )
{
	destroy( m_interactive_motion );
	m_PhysicMovementControl->DestroyCharacter( );

	if( m_physics_skeleton )
	{
		m_physics_skeleton->Deactivate( );
		xr_delete( m_physics_skeleton );
	}
	if(m_pPhysicsShell)
	{
		m_pPhysicsShell->Deactivate();
		xr_delete( m_pPhysicsShell );
	}

	m_flags.set( fl_skeleton_in_shell, FALSE );
	CPHSkeleton::RespawnInit( );
	CPHDestroyable::RespawnInit( );
	m_eState = esAlive;
	
	xr_delete( m_interactive_animation );
	destroy_animation_collision();
	DestroyIKController( );
	xr_delete( m_collision_activating_delay );
}
void CCharacterPhysicsSupport::in_ChangeVisual()
{
	
	if(!m_physics_skeleton&&!m_pPhysicsShell) return;

	if(m_pPhysicsShell)
	{
		VERIFY(m_eType!=etStalker);
		if(m_physics_skeleton)
		{
			m_EntityAlife.processing_deactivate()	;
			m_physics_skeleton->Deactivate()		;
			xr_delete(m_physics_skeleton)			;
		}
		CreateSkeleton(m_physics_skeleton);
		if(m_pPhysicsShell)m_pPhysicsShell->Deactivate();
		xr_delete(m_pPhysicsShell);
		ActivateShell(NULL);
	}
	if(m_ik_controller)
	{
		DestroyIKController();
		CreateIKController();
	}
}
Example #3
0
void CCharacterPhysicsSupport::KillHit( SHit &H )
{
#ifdef	DEBUG
	if( death_anim_debug )
			Msg( "death anim: kill hit  " );
#endif
	VERIFY( m_EntityAlife.Visual( ) );
	VERIFY( m_EntityAlife.Visual( )->dcast_PKinematics( ) );
	m_character_shell_control.TestForWounded( m_EntityAlife.XFORM( ), m_EntityAlife.Visual( )->dcast_PKinematics( ) );
	Fmatrix prev_pose; prev_pose.set( mXFORM );

	Fvector start;start.set( m_EntityAlife.Position( ) );
	Fvector velocity;
	Fvector death_position;
	CreateShell( H.who, death_position, velocity );
	//ActivateShell( H.who );

//	if(Type() == etStalker && xr_strcmp(dbg_stalker_death_anim, "none") != 0)
	float hit_angle = 0;
	MotionID m = m_death_anims.motion( m_EntityAlife, H, hit_angle );

	CAI_Stalker* const	holder = m_EntityAlife.cast_stalker();
	if (holder && (holder->wounded() || holder->movement().current_params().cover()) )
		m		= MotionID();

	if( m.valid( ) )//&& cmp( prev_pose, mXFORM ) 
	{
		destroy( m_interactive_motion );
		if( false && b_death_anim_velocity )
			m_interactive_motion = new imotion_velocity( );
		else
			m_interactive_motion = new imotion_position( );
		m_interactive_motion->setup( m ,m_pPhysicsShell, hit_angle );
	} else 
		DestroyIKController( );

	if( is_imotion(m_interactive_motion ) )
				m_interactive_motion->play( );


	m_character_shell_control.set_fatal_impulse( H );

	if( !is_imotion( m_interactive_motion ) )
	{
		
#ifdef	DEBUG
		if( death_anim_debug )
		{
			Msg( "death anim: kill hit use free ragdoll " );
			Msg( "death anim: fatal impulse: %f, ", H.impulse );
		}
#endif
		
		EndActivateFreeShell( H.who, start ,death_position, velocity );	
		m_flags.set( fl_block_hit, TRUE );
	}
}
Example #4
0
IC		void	CCharacterPhysicsSupport::						UpdateDeathAnims				()
{
	VERIFY(m_pPhysicsShell->isFullActive());

	if(!m_flags.test(fl_death_anim_on) && !is_imotion(m_interactive_motion))//!m_flags.test(fl_use_death_motion)//!b_death_anim_on&&m_pPhysicsShell->isFullActive()
	{
		DestroyIKController( );
		smart_cast<IKinematicsAnimated*>(m_EntityAlife.Visual())->PlayCycle("death_init");
		m_flags.set(fl_death_anim_on,TRUE);
	}
}
Example #5
0
void CCharacterPhysicsSupport::in_ChangeVisual()
{
	
	if(m_ik_controller)
	{
		DestroyIKController();
		CreateIKController();
	}
	xr_delete( m_interactive_animation );
	destroy_animation_collision();
	destroy( m_interactive_motion );
	IKinematicsAnimated* KA = smart_cast<IKinematicsAnimated*>( m_EntityAlife.Visual( ) );
	if( KA )
	{
		m_death_anims.setup( KA, m_EntityAlife.cNameSect().c_str() , pSettings );
		if( Type( ) != etBitting )
				m_hit_animations.SetupHitMotions( *KA );
	}

	if(!m_physics_skeleton&&!m_pPhysicsShell) return;

	if(m_pPhysicsShell)
	{
		VERIFY(m_eType!=etStalker);
		if(m_physics_skeleton)
		{
			m_EntityAlife.processing_deactivate()	;
			m_physics_skeleton->Deactivate()		;
			xr_delete(m_physics_skeleton)			;
		}
		CreateSkeleton(m_physics_skeleton);
		if(m_pPhysicsShell)m_pPhysicsShell->Deactivate();
		xr_delete(m_pPhysicsShell);
		ActivateShell(NULL);
	}

}
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);
}