void CRagdollProp::Spawn( void ) { // Starts out as the default fade scale value m_flDefaultFadeScale = m_flFadeScale; // NOTE: If this fires, then the assert or the datadesc is wrong! (see DEFINE_RAGDOLL_ELEMENT above) Assert( RAGDOLL_MAX_ELEMENTS == 24 ); Precache(); SetModel( STRING( GetModelName() ) ); CStudioHdr *pStudioHdr = GetModelPtr( ); if ( pStudioHdr->flags() & STUDIOHDR_FLAGS_NO_FORCED_FADE ) { DisableAutoFade(); } else { m_flFadeScale = m_flDefaultFadeScale; } matrix3x4_t pBoneToWorld[MAXSTUDIOBONES]; BaseClass::SetupBones( pBoneToWorld, BONE_USED_BY_ANYTHING ); // FIXME: shouldn't this be a subset of the bones // this is useless info after the initial conditions are set SetAbsAngles( vec3_angle ); int collisionGroup = (m_spawnflags & SF_RAGDOLLPROP_DEBRIS) ? COLLISION_GROUP_DEBRIS : COLLISION_GROUP_NONE; InitRagdoll( vec3_origin, 0, vec3_origin, pBoneToWorld, pBoneToWorld, 0, collisionGroup, true ); m_lastUpdateTickCount = 0; m_flBlendWeight = 0.0f; m_nOverlaySequence = -1; // Unless specified, do not allow this to be dissolved if ( HasSpawnFlags( SF_RAGDOLLPROP_ALLOW_DISSOLVE ) == false ) { AddEFlags( EFL_NO_DISSOLVE ); } }
bool StudioModel::LoadModel( const char *pModelName ) { MDLCACHE_CRITICAL_SECTION_( g_pMDLCache ); if (!pModelName) return 0; // In the case of restore, m_pModelName == modelname if (m_pModelName != pModelName) { // Copy over the model name; we'll need it later... if (m_pModelName) { delete[] m_pModelName; } m_pModelName = new char[Q_strlen(pModelName) + 1]; strcpy( m_pModelName, pModelName ); } m_MDLHandle = g_pMDLCache->FindMDL( pModelName ); // allocate a pool for a studiohdr cache if (m_pStudioHdr != NULL) { delete m_pStudioHdr; } m_pStudioHdr = new CStudioHdr( g_pMDLCache->GetStudioHdr( m_MDLHandle ), g_pMDLCache ); // manadatory to access correct verts SetCurrentModel(); m_pPhysics = LoadPhysics( m_MDLHandle ); // Copy over all of the hitboxes; we may add and remove elements m_HitboxSets.RemoveAll(); CStudioHdr *pStudioHdr = GetStudioHdr(); int i; for ( int s = 0; s < pStudioHdr->numhitboxsets(); s++ ) { mstudiohitboxset_t *set = pStudioHdr->pHitboxSet( s ); if ( !set ) continue; m_HitboxSets.AddToTail(); for ( i = 0; i < set->numhitboxes; ++i ) { mstudiobbox_t *pHit = set->pHitbox(i); int nIndex = m_HitboxSets[ s ].AddToTail( ); m_HitboxSets[s][nIndex] = *pHit; } // Set the name hbsetname_s *n = &m_HitboxSetNames[ m_HitboxSetNames.AddToTail() ]; strcpy( n->name, set->pszName() ); } // Copy over all of the surface props; we may change them... for ( i = 0; i < pStudioHdr->numbones(); ++i ) { mstudiobone_t* pBone = pStudioHdr->pBone(i); CUtlSymbol prop( pBone->pszSurfaceProp() ); m_SurfaceProps.AddToTail( prop ); } m_physPreviewBone = -1; bool forceOpaque = (pStudioHdr->flags() & STUDIOHDR_FLAGS_FORCE_OPAQUE) != 0; bool vertexLit = false; m_bIsTransparent = false; m_bHasProxy = false; studiohwdata_t *pHardwareData = g_pMDLCache->GetHardwareData( m_MDLHandle ); if ( !pHardwareData ) { Assert( 0 ); return false; } for( int lodID = pHardwareData->m_RootLOD; lodID < pHardwareData->m_NumLODs; lodID++ ) { studioloddata_t *pLODData = &pHardwareData->m_pLODs[lodID]; for ( i = 0; i < pLODData->numMaterials; ++i ) { if (pLODData->ppMaterials[i]->IsVertexLit()) { vertexLit = true; } if ((!forceOpaque) && pLODData->ppMaterials[i]->IsTranslucent()) { m_bIsTransparent = true; //Msg("Translucent material %s for model %s\n", pLODData->ppMaterials[i]->GetName(), pStudioHdr->name ); } if (pLODData->ppMaterials[i]->HasProxy()) { m_bHasProxy = true; } } } return true; }