MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / LoadCharacter

Method LoadCharacter

CryEntitySystem/EntityCreation.cpp:688–742  ·  view source on GitHub ↗

load a model for this entity /////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

686//load a model for this entity
687//////////////////////////////////////////////////////////////////////
688bool CEntity::LoadCharacter( int pos,const char *filename )
689{
690 CHECK_CHARACTER_SLOT_0( "CEntity::LoadCharacter" );
691// m_pISystem->GetI3DEngine()->RemoveCharacter(m_pCryCharInstance[pos]);
692
693 ICryCharInstance *prevChar = m_pCryCharInstance[pos];
694 if (prevChar)
695 {
696 if (prevChar->IsModelFileEqual(filename))
697 {
698 // Trying to load already load character, then silently ignore it.
699 prevChar->ResetAnimations();
700 // [Anton] it is essential that when a character is loaded (and later physicalized) that
701 // both cases (i.e. model loading and model reusing) act the same and create character in the same default
702 // position. ResetAnimations is not enough to achieve that.
703 prevChar->StartAnimation("default",0.0f);
704 prevChar->Update();
705 return true;
706 }
707 }
708
709 //@FIXME put range check here.
710 m_pHeadBone = 0;
711 ReleaseLipSyncInterface(); // we release lipsync before we destroy the character...
712 m_pCryCharInstance[pos]=NULL;
713
714// CLog::Log("Loading character: %s ...", filename);
715
716 // First Create new character.
717 m_pCryCharInstance[pos] = m_pISystem->GetIAnimationSystem()->MakeCharacter(filename);
718 // After that delete previous chracter.
719 if (prevChar)
720 m_pISystem->GetIAnimationSystem()->RemoveCharacter(prevChar);
721// m_pCryCharInstance[pos]->SetCharInstanceSink(this);
722 if(m_pCryCharInstance[pos])
723 {
724 m_bUpdateCharacters = true;
725 if(m_nMaxCharNum>=pos)
726 m_nMaxCharNum=pos+1;
727
728 m_pCryCharInstance[pos]->SetFlags(m_pCryCharInstance[pos]->GetFlags() | CS_FLAG_DRAW_MODEL);
729 m_pCryCharInstance[pos]->SetFlags(m_pCryCharInstance[pos]->GetFlags() | CS_FLAG_UPDATE);
730
731
732 m_pHeadBone = m_pCryCharInstance[0]->GetBoneByName("Bip01 Head");
733 }
734
735 m_pISystem->GetI3DEngine()->FreeEntityRenderState(this);
736 InitEntityRenderState();
737
738 // leave this call... it will cause the geometry to be properly registered
739 CalcWholeBBox();
740
741 return m_pCryCharInstance[pos]!=0;
742}
743
744bool CEntity::PhysicalizeCharacter(int pos, float mass,int surface_idx,float stiffness_scale, bool bInstant)
745{

Callers

nothing calls this directly

Calls 12

GetIAnimationSystemMethod · 0.80
FreeEntityRenderStateMethod · 0.80
GetI3DEngineMethod · 0.80
IsModelFileEqualMethod · 0.45
ResetAnimationsMethod · 0.45
StartAnimationMethod · 0.45
UpdateMethod · 0.45
MakeCharacterMethod · 0.45
RemoveCharacterMethod · 0.45
SetFlagsMethod · 0.45
GetFlagsMethod · 0.45
GetBoneByNameMethod · 0.45

Tested by

no test coverage detected