//----------------------------------------------------------------------------- // Purpose: Draws the object // Input : flags - //----------------------------------------------------------------------------- bool C_PhysicsProp::OnInternalDrawModel( ClientModelRenderInfo_t *pInfo ) { CreateModelInstance(); if ( r_PhysPropStaticLighting.GetBool() && m_bAwakeLastTime != m_bAwake ) { if ( m_bAwakeLastTime && !m_bAwake ) { // transition to sleep, bake lighting now, once if ( !modelrender->RecomputeStaticLighting( GetModelInstance() ) ) { // not valid for drawing return false; } if ( r_visualizeproplightcaching.GetBool() ) { float color[] = { 0.0f, 1.0f, 0.0f, 1.0f }; render->SetColorModulation( color ); } } else if ( r_visualizeproplightcaching.GetBool() ) { float color[] = { 1.0f, 0.0f, 0.0f, 1.0f }; render->SetColorModulation( color ); } } if ( !m_bAwake && r_PhysPropStaticLighting.GetBool() ) { // going to sleep, have static lighting pInfo->flags |= STUDIO_STATIC_LIGHTING; } // track state m_bAwakeLastTime = m_bAwake; return true; }
/* * Copy entity from another entity of same class. * NOTES: * - Doesn't copy placement, it must be done on creation. * - Entity must be initialized afterwards. */ void CEntity::Copy(CEntity &enOther, ULONG ulFlags) { BOOL bRemapPointers = ulFlags & COPY_REMAP; // copy base class data en_RenderType = enOther.en_RenderType; en_ulPhysicsFlags = enOther.en_ulPhysicsFlags; en_ulCollisionFlags = enOther.en_ulCollisionFlags; en_ulFlags = enOther.en_ulFlags & ~(ENF_SELECTED|ENF_FOUNDINGRIDSEARCH|ENF_VALIDSHADINGINFO|ENF_INRENDERING); en_ulSpawnFlags = enOther.en_ulSpawnFlags; // if this is a brush if ( enOther.en_RenderType == RT_BRUSH || en_RenderType == RT_FIELDBRUSH) { // there must be no existing brush ASSERT(en_pbrBrush == NULL); // create a new empty brush in the brush archive of current world en_pbrBrush = en_pwoWorld->wo_baBrushes.ba_abrBrushes.New(); en_pbrBrush->br_penEntity = this; // copy the brush if (_bMirrorAndStretch) { en_pbrBrush->Copy(*enOther.en_pbrBrush, _fStretch, _wmtMirror!=WMT_NONE); } else { en_pbrBrush->Copy(*enOther.en_pbrBrush, 1.0f, FALSE); } // if this is a terrain } else if( enOther.en_RenderType == RT_TERRAIN) { ASSERT(en_ptrTerrain == NULL); // create a new empty terrain in the brush archive of current world en_ptrTerrain = en_pwoWorld->wo_taTerrains.ta_atrTerrains.New(); en_ptrTerrain->tr_penEntity = this; // Copy terrain TR_CopyTerrain(en_ptrTerrain,enOther.en_ptrTerrain); // Update terrain shadowmap Matrix12 mTerrain; TR_GetMatrixFromEntity(mTerrain,en_ptrTerrain); TR_UpdateShadowMap(en_ptrTerrain,mTerrain,FLOATaabbox3D()); // if this is a model } if ( enOther.en_RenderType == RT_MODEL || en_RenderType == RT_EDITORMODEL) { // if will not initialize if (!(ulFlags©_REINIT)) { ASSERT(en_pmoModelObject==NULL); ASSERT(en_psiShadingInfo==NULL); if(en_pmoModelObject!=NULL) { delete en_pmoModelObject; } if(en_psiShadingInfo!=NULL) { delete en_psiShadingInfo; } // create a new model object en_pmoModelObject = new CModelObject; en_psiShadingInfo = new CShadingInfo; en_ulFlags &= ~ENF_VALIDSHADINGINFO; // copy it en_pmoModelObject->Copy(*enOther.en_pmoModelObject); } // if this is ska model } else if ( enOther.en_RenderType == RT_SKAMODEL || en_RenderType == RT_SKAEDITORMODEL) { ASSERT(en_psiShadingInfo==NULL); if(en_psiShadingInfo!=NULL) { delete en_psiShadingInfo; } en_psiShadingInfo = new CShadingInfo; en_ulFlags &= ~ENF_VALIDSHADINGINFO; ASSERT(en_pmiModelInstance==NULL); if(en_pmiModelInstance!=NULL) { DeleteModelInstance(en_pmiModelInstance); } en_pmiModelInstance = CreateModelInstance(""); // copy it GetModelInstance()->Copy(*enOther.GetModelInstance()); } // copy the parent pointer if (bRemapPointers) { en_penParent = FindRemappedEntityPointer(enOther.en_penParent); } else { en_penParent = enOther.en_penParent; } // if the entity has a parent if (en_penParent!=NULL) { // create relative offset en_plRelativeToParent = en_plPlacement; en_plRelativeToParent.AbsoluteToRelativeSmooth(en_penParent->en_plPlacement); // link to parent en_penParent->en_lhChildren.AddTail(en_lnInParent); } // copy the derived class properties CopyEntityProperties(enOther, ulFlags); }
//----------------------------------------------------------------------------- // Purpose: Draws the object //----------------------------------------------------------------------------- int C_NPC_Barnacle::InternalDrawModel( int flags ) { if ( !GetModel() ) return 0; // Make sure hdr is valid for drawing if ( !GetModelPtr() ) return 0; // UNDONE: With a bit of work on the model->world transform, we can probably // move the frustum culling into the client DLL entirely. Then TestVisibility() // can just return true/false and only be called when frustumcull is set. if ( flags & STUDIO_FRUSTUMCULL ) { switch ( TestVisibility() ) { // not visible, don't draw case VIS_NOT_VISIBLE: return 0; // definitely visible, disable engine check case VIS_IS_VISIBLE: flags &= ~STUDIO_FRUSTUMCULL; break; default: case VIS_USE_ENGINE: break; } } Vector vecMins, vecMaxs; GetRenderBounds( vecMins, vecMaxs ); int drawn = modelrender->DrawModel( flags, this, GetModelInstance(), index, GetModel(), GetAbsOrigin(), GetAbsAngles(), GetSequence(), m_nSkin, m_nBody, m_nHitboxSet, &GetAbsMins(), &GetAbsMaxs() ); if ( vcollide_wireframe.GetBool() ) { if ( IsRagdoll() ) { m_pRagdoll->DrawWireframe(); } else { vcollide_t *pCollide = modelinfo->GetVCollide( GetModelIndex() ); if ( pCollide && pCollide->solidCount == 1 ) { static color32 debugColor = {0,255,255,0}; matrix3x4_t matrix; AngleMatrix( GetAbsAngles(), GetAbsOrigin(), matrix ); engine->DebugDrawPhysCollide( pCollide->solids[0], NULL, matrix, debugColor ); } } } return drawn; }