void CPhysicObject::set_door_ignore_dynamics ( ) { R_ASSERT(PPhysicsShell()); PPhysicsShell()->remove_ObjectContactCallback( door_ignore ); PPhysicsShell()->add_ObjectContactCallback( door_ignore ); //PPhysicsShell()-> }
bool CCar::attach_Actor(CGameObject* actor) { if(Owner()||CPHDestroyable::Destroyed()) return false; CHolderCustom::attach_Actor(actor); IKinematics* K = smart_cast<IKinematics*>(Visual()); CInifile* ini = K->LL_UserData(); int id; if(ini->line_exist("car_definition","driver_place")) id=K->LL_BoneID(ini->r_string("car_definition","driver_place")); else { Owner()->setVisible(0); id=K->LL_GetBoneRoot(); } CBoneInstance& instance=K->LL_GetBoneInstance (u16(id)); m_sits_transforms.push_back(instance.mTransform); OnCameraChange(ectFirst); PPhysicsShell()->Enable(); PPhysicsShell()->add_ObjectContactCallback(ActorObstacleCallback); // VisualUpdate(); processing_activate(); ReleaseHandBreak(); // CurrentGameUI()->UIMainIngameWnd->CarPanel().Show(true); // CurrentGameUI()->UIMainIngameWnd->CarPanel().SetCarHealth(fEntityHealth/100.f); //CurrentGameUI()->UIMainIngameWnd.ShowBattery(true); //CBoneData& bone_data=K->LL_GetData(id); //Fmatrix driver_pos_tranform; //driver_pos_tranform.setHPB(bone_data.bind_hpb.x,bone_data.bind_hpb.y,bone_data.bind_hpb.z); //driver_pos_tranform.c.set(bone_data.bind_translate); //m_sits_transforms.push_back(driver_pos_tranform); //H_SetParent(actor); return true; }
void CPhysicsShellHolder:: save (NET_Packet &output_packet) { inherited::save(output_packet); u8 enable_state=(u8)stNotDefitnite; if(PPhysicsShell()&&PPhysicsShell()->isActive()) { enable_state=u8(PPhysicsShell()->isEnabled() ? stEnable:stDisable); } output_packet.w_u8(enable_state); }
void CHelicopter::UpdateCL() { inherited::UpdateCL (); CExplosive::UpdateCL(); if(PPhysicsShell() && (state() == CHelicopter::eDead) ) { PPhysicsShell()->InterpolateGlobalTransform(&XFORM()); IKinematics* K = smart_cast<IKinematics*>(Visual()); K->CalculateBones (); //smoke UpdateHeliParticles(); if(m_brokenSound._feedback()) m_brokenSound.set_position(XFORM().c); return; } else PPhysicsShell()->SetTransform(XFORM(), mh_unspecified ); m_movement.Update(); m_stepRemains+=Device.fTimeDelta; while(m_stepRemains>STEP) { MoveStep(); m_stepRemains-=STEP; } #ifdef DEBUG if(bDebug) { CGameFont* F = UI().Font().pFontDI; F->SetAligment (CGameFont::alCenter); // F->SetSizeI (0.02f); F->OutSetI (0.f,-0.8f); F->SetColor (0xffffffff); F->OutNext ("Heli: speed=%4.4f acc=%4.4f dist=%4.4f",m_movement.curLinearSpeed, m_movement.curLinearAcc, m_movement.GetDistanceToDestPosition()); } #endif if(m_engineSound._feedback()) m_engineSound.set_position(XFORM().c); m_enemy.Update(); //weapon UpdateWeapons(); UpdateHeliParticles(); IKinematics* K = smart_cast<IKinematics*>(Visual()); K->CalculateBones (); }
void CHelicopter::SpawnInitPhysics (CSE_Abstract *D) { PPhysicsShell()=P_build_Shell (this,false); if(g_Alive()) { PPhysicsShell()->EnabledCallbacks (FALSE); PPhysicsShell()->set_ObjectContactCallback (CollisionCallbackAlife); PPhysicsShell()->set_ContactCallback (ContactCallbackAlife); PPhysicsShell()->Disable (); } }
void CCar::PhTune(float step) { for(u16 i=PPhysicsShell()->get_ElementsNumber();i!=0;i--) { CPhysicsElement* e=PPhysicsShell()->get_ElementByStoreOrder(i-1); if(e->isActive()&&e->isEnabled()) e->applyForce( 0, e->getMass()*AntiGravityAccel(), 0 ); //dBodyAddForce(e->get_body(),0,e->getMass()*AntiGravityAccel(),0); } }
void CPhysicsShellHolder::UpdateXFORM(const Fmatrix &upd) { inherited::UpdateXFORM(upd); static int method = 1 + 4 + 8; // alpet: набор флагов для отладки, можно менять значение во время выполнения из Watches if (PPhysicsShell()) { // m_pPhysicsShell->SetTransform(upd); if (method & 1) { PPhysicsShell()->mXFORM.set(upd); PPhysicsShell()->SetGlTransformDynamic(upd); } if (method & 2) { // стянуто из Car.cpp и как-то не так работает bool enable = PPhysicsShell()->isEnabled(); Fmatrix inv, replace; Fmatrix restored_form; PPhysicsShell()->GetGlobalTransformDynamic(&restored_form); inv.set(restored_form); inv.invert(); replace.mul(upd, inv); PPhysicsShell()->SetTransform (replace); if (enable) PPhysicsShell()->Enable(); else PPhysicsShell()->Disable(); // PPhysicsShell()->GetGlobalTransformDynamic(&XFORM()); } // пересчет костей CKinematics *K = PKinematics(Visual()); if (K) { K->CalculateBones_Invalidate(); K->CalculateBones(); } if (method & 4) PPhysicsShell()->Update(); if (method & 8) PPhysicsShell()->GetGlobalTransformDynamic(&XFORM()); } }
void CPhysicsShellHolder::activate_physic_shell() { VERIFY (!m_pPhysicsShell); create_physic_shell (); Fvector l_fw, l_up; l_fw.set (XFORM().k); l_up.set (XFORM().j); l_fw.mul (2.f); l_up.mul (2.f); Fmatrix l_p1, l_p2; l_p1.set (XFORM()); l_p2.set (XFORM()); l_fw.mul (2.f); l_p2.c.add (l_fw); m_pPhysicsShell->Activate (l_p1, 0, l_p2); if(H_Parent()&&H_Parent()->Visual()) { smart_cast<CKinematics*>(H_Parent()->Visual())->CalculateBones_Invalidate (); smart_cast<CKinematics*>(H_Parent()->Visual())->CalculateBones (); } smart_cast<CKinematics*>(Visual())->CalculateBones_Invalidate (); smart_cast<CKinematics*>(Visual())->CalculateBones(); if(!IsGameTypeSingle()) { if(!smart_cast<CCustomRocket*>(this)&&!smart_cast<CGrenade*>(this)) PPhysicsShell()->SetIgnoreDynamic(); } // XFORM().set (l_p1); correct_spawn_pos(); m_pPhysicsShell->set_LinearVel(l_fw); m_pPhysicsShell->GetGlobalTransformDynamic(&XFORM()); }
void CHangingLamp::TurnOff () { light_render->set_active (false); if (glow_render) glow_render->set_active (false); if (light_ambient) light_ambient->set_active (false); if (Visual()) smart_cast<CKinematics*>(Visual())->LL_SetBoneVisible(light_bone, FALSE, TRUE); if(!PPhysicsShell())//if we have physiccs_shell it will call processing deactivate when disable processing_deactivate (); }
void CArtefact::MoveTo(Fvector const & position) { if (!PPhysicsShell()) return; Fmatrix M = XFORM(); M.translate(position); ForceTransform(M); //m_bInInterpolation = false; }
Fvector CCar:: ExitVelocity () { CPhysicsShell *P=PPhysicsShell(); if(!P||!P->isActive())return Fvector().set(0,0,0); CPhysicsElement *E=P->get_ElementByStoreOrder(0); Fvector v=ExitPosition(); E->GetPointVel( v, v ); //dBodyGetPointVel(E->get_body(),v.x,v.y,v.z,cast_fp(v)); return v; }
BOOL CPhysicObject::net_Spawn(CSE_Abstract* DC) { CSE_Abstract *e = (CSE_Abstract*)(DC); CSE_ALifeObjectPhysic *po = smart_cast<CSE_ALifeObjectPhysic*>(e); R_ASSERT (po); m_type = EPOType(po->type); m_mass = po->mass; m_collision_hit_callback= NULL; m_anim_blend = 0; inherited::net_Spawn ( DC ); create_collision_model ( ); CPHSkeleton::Spawn(e); setVisible(TRUE); setEnabled(TRUE); if (!PPhysicsShell()->isBreakable()&&!CScriptBinder::object()&&!CPHSkeleton::IsRemoving()) SheduleUnregister(); //if (PPhysicsShell()->Animated()) //{ // processing_activate(); //} bones_snd_player = create_moving_bones_snd_player( *this ); if( bones_snd_player ) play_bones_sound(); m_just_after_spawn = true; m_activated = false; if (DC->s_flags.is(M_SPAWN_UPDATE)) { NET_Packet temp; temp.B.count = 0; DC->UPDATE_Write (temp); if (temp.B.count > 0) { temp.r_seek (0); net_Import (temp); } } //processing_activate(); #ifdef DEBUG if(dbg_draw_doors) { DBG_OpenCashedDraw( ); Fvector closed, open; get_door_vectors( closed, open ); DBG_ClosedCashedDraw( 50000000 ); } #endif return TRUE; }
void CPoltergeist::Die(CObject* who) { if (m_tele) { if (state_invisible) { setVisible(true); if (PPhysicsShell()) { Fmatrix M; M.set (XFORM()); M.translate_over (m_current_position); PPhysicsShell()->SetTransform (M); } else Position() = m_current_position; } } inherited::Die (who); Energy::disable (); ability()->on_die (); }
BOOL CAI_Boar::net_Spawn (CSE_Abstract* DC) { if (!inherited::net_Spawn(DC)) return(FALSE); if(!PPhysicsShell())//нельзя ставить колбеки, если создан физ шел - у него стоят свои колбеки!!! { CBoneInstance& BI = smart_cast<CKinematics*>(Visual())->LL_GetBoneInstance(smart_cast<CKinematics*>(Visual())->LL_BoneID("bip01_head")); BI.set_callback(bctCustom,BoneCallback,this); } _cur_delta = _target_delta = 0.f; _velocity = PI; look_at_enemy = false; return TRUE; }
BOOL CWeaponStatMgun::net_Spawn(CSE_Abstract* DC) { if(!inheritedPH::net_Spawn (DC)) return FALSE; IKinematics* K = smart_cast<IKinematics*>(Visual()); CInifile* pUserData = K->LL_UserData(); R_ASSERT2 (pUserData,"Empty WeaponStatMgun user data!"); m_rotate_x_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","rotate_x_bone")); m_rotate_y_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","rotate_y_bone")); m_fire_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","fire_bone")); m_camera_bone = K->LL_BoneID (pUserData->r_string("mounted_weapon_definition","camera_bone")); U16Vec fixed_bones; fixed_bones.push_back (K->LL_GetBoneRoot()); PPhysicsShell() = P_build_Shell(this,false,fixed_bones); CBoneData& bdX = K->LL_GetData(m_rotate_x_bone); VERIFY(bdX.IK_data.type==jtJoint); m_lim_x_rot.set (bdX.IK_data.limits[0].limit.x,bdX.IK_data.limits[0].limit.y); CBoneData& bdY = K->LL_GetData(m_rotate_y_bone); VERIFY(bdY.IK_data.type==jtJoint); m_lim_y_rot.set (bdY.IK_data.limits[1].limit.x,bdY.IK_data.limits[1].limit.y); xr_vector<Fmatrix> matrices; K->LL_GetBindTransform (matrices); m_i_bind_x_xform.invert (matrices[m_rotate_x_bone]); m_i_bind_y_xform.invert (matrices[m_rotate_y_bone]); m_bind_x_rot = matrices[m_rotate_x_bone].k.getP(); m_bind_y_rot = matrices[m_rotate_y_bone].k.getH(); m_bind_x.set (matrices[m_rotate_x_bone].c); m_bind_y.set (matrices[m_rotate_y_bone].c); m_cur_x_rot = m_bind_x_rot; m_cur_y_rot = m_bind_y_rot; m_destEnemyDir.setHP (m_bind_y_rot,m_bind_x_rot); XFORM().transform_dir (m_destEnemyDir); inheritedShooting::Light_Create(); processing_activate (); setVisible (TRUE); setEnabled (TRUE); return TRUE; }
void CPhysicsShellHolder::correct_spawn_pos() { VERIFY (PPhysicsShell()); if( H_Parent() ) { CPhysicsShellHolder * P = smart_cast<CPhysicsShellHolder*>(H_Parent()); if( P && P->has_shell_collision_place(this) ) return; } Fvector size; Fvector c; get_box (PPhysicsShell(),XFORM(),size,c); R_ASSERT2( _valid( c ), make_string( "object: %s model: %s ", cName().c_str(), cNameVisual().c_str() ) ); R_ASSERT2( _valid( size ), make_string( "object: %s model: %s ", cName().c_str(), cNameVisual().c_str() ) ); R_ASSERT2( _valid( XFORM() ), make_string( "object: %s model: %s ", cName().c_str(), cNameVisual().c_str() ) ); CPHActivationShape activation_shape; activation_shape.Create (c,size,this); activation_shape.set_rotation (XFORM()); PPhysicsShell()->DisableCollision (); activation_shape.Activate (size,1,1.f,M_PI/8.f); //// VERIFY (valid_pos(activation_shape.Position(),phBoundaries)); // if (!valid_pos(activation_shape.Position(),phBoundaries)) { // CPHActivationShape activation_shape; // activation_shape.Create (c,size,this); // activation_shape.set_rotation (XFORM()); // activation_shape.Activate (size,1,1.f,M_PI/8.f); //// VERIFY (valid_pos(activation_shape.Position(),phBoundaries)); // } PPhysicsShell()->EnableCollision (); Fvector ap = activation_shape.Position(); #ifdef DEBUG if (!valid_pos(ap,phBoundaries)) { Msg("not valid position %f,%f,%f",ap.x,ap.y,ap.z); Msg("size %f,%f,%f",size.x,size.y,size.z); Msg("Object: %s",Name()); Msg("Visual: %s",*(cNameVisual())); Msg("Object pos %f,%f,%f",Position().x,Position().y,Position().z); } #endif // DEBUG VERIFY (valid_pos(activation_shape.Position(),phBoundaries)); Fmatrix trans; trans.identity (); trans.c.sub (ap,c); PPhysicsShell()->TransformPosition (trans); PPhysicsShell()->GetGlobalTransformDynamic(&XFORM()); activation_shape.Destroy (); }
void CPhysicObject::net_Export (NET_Packet& P) { if (this->H_Parent() || IsGameTypeSingle()) { P.w_u8 (0); return; } CPHSynchronize* pSyncObj = NULL; SPHNetState State; pSyncObj = this->PHGetSyncItem (0); if (pSyncObj && !this->H_Parent()) pSyncObj->get_State (State); else State.position.set (this->Position()); mask_num_items num_items; num_items.mask = 0; u16 temp = this->PHGetSyncItemsNumber(); R_ASSERT (temp < (u16(1) << 5)); num_items.num_items = u8(temp); if (State.enabled) num_items.mask |= CSE_ALifeObjectPhysic::inventory_item_state_enabled; if (fis_zero(State.angular_vel.square_magnitude())) num_items.mask |= CSE_ALifeObjectPhysic::inventory_item_angular_null; if (fis_zero(State.linear_vel.square_magnitude())) num_items.mask |= CSE_ALifeObjectPhysic::inventory_item_linear_null; //if (m_pPhysicsShell->PPhysicsShellAnimator()) {num_items.mask |= CSE_ALifeObjectPhysic::animated;} P.w_u8 (num_items.common); /*if (num_items.mask&CSE_ALifeObjectPhysic::animated) { net_Export_Anim_Params(P); }*/ net_Export_PH_Params(P,State,num_items); if (PPhysicsShell()->isEnabled()) { P.w_u8(1); //not freezed } else { P.w_u8(0); //freezed } };
BOOL CPhysicItem::net_Spawn (CSE_Abstract* DC) { if (!inherited::net_Spawn(DC)) return (FALSE); smart_cast<CKinematics*>(Visual())->CalculateBones_Invalidate (); smart_cast<CKinematics*>(Visual())->CalculateBones (); CSE_Abstract *abstract = (CSE_Abstract*)DC; if (0xffff == abstract->ID_Parent) { if(!PPhysicsShell())setup_physic_shell (); //else processing_deactivate();//. } setVisible (TRUE); setEnabled (TRUE); return (TRUE); }
void CCar::detach_Actor() { if(!Owner()) return; Owner()->setVisible(1); CHolderCustom::detach_Actor(); PPhysicsShell()->remove_ObjectContactCallback(ActorObstacleCallback); NeutralDrive(); Unclutch(); ResetKeys(); m_current_rpm=m_min_rpm; // CurrentGameUI()->UIMainIngameWnd->CarPanel().Show(false); ///Break(); //H_SetParent(NULL); HandBreak(); processing_deactivate(); #ifdef DEBUG DBgClearPlots(); #endif }
void CHelicopter::DieHelicopter() { if ( state() == CHelicopter::eDead ) return; CEntity::Die(NULL); m_engineSound.stop (); m_brokenSound.create (pSettings->r_string(*cNameSect(), "broken_snd"),st_Effect,sg_SourceType); m_brokenSound.play_at_pos (0,XFORM().c,sm_Looped); CKinematics* K = smart_cast<CKinematics*>(Visual()); if(true /*!PPhysicsShell()*/){ string256 I; LPCSTR bone; u16 bone_id; for (u32 i=0, n=_GetItemCount(*m_death_bones_to_hide); i<n; ++i){ bone = _GetItem(*m_death_bones_to_hide,i,I); bone_id = K->LL_BoneID (bone); K->LL_SetBoneVisible(bone_id,FALSE,TRUE); } ///PPhysicsShell()=P_build_Shell (this,false); PPhysicsShell()->EnabledCallbacks(TRUE); PPhysicsShell()->set_ObjectContactCallback(CollisionCallbackDead); PPhysicsShell()->set_ContactCallback(ContactShotMark); } Fvector lin_vel; Fvector prev_pos = PositionStack.front().vPosition; lin_vel.sub (XFORM().c,prev_pos); if(Device.dwTimeGlobal != PositionStack.front().dwTime) lin_vel.div((Device.dwTimeGlobal-PositionStack.front().dwTime)/1000.0f); lin_vel.mul (m_death_lin_vel_k); PPhysicsShell()->set_LinearVel (lin_vel); PPhysicsShell()->set_AngularVel (m_death_ang_vel); PPhysicsShell()->Enable (); K->CalculateBones_Invalidate (); K->CalculateBones (); setState (CHelicopter::eDead); m_engineSound.stop (); processing_deactivate (); m_dead = true; }
void CPhysicObject::PH_A_CrPr () { if (m_just_after_spawn) { VERIFY(Visual()); IKinematics *K = Visual()->dcast_PKinematics(); VERIFY( K ); if (!PPhysicsShell()) { return; } if(!PPhysicsShell()->isFullActive()) { K->CalculateBones_Invalidate(); K->CalculateBones(TRUE); } PPhysicsShell()->GetGlobalTransformDynamic(&XFORM()); K->CalculateBones_Invalidate(); K->CalculateBones(TRUE); #if 0 Fbox bb= BoundingBox (); DBG_OpenCashedDraw (); Fvector c,r,p; bb.get_CD(c,r ); XFORM().transform_tiny(p,c); DBG_DrawAABB( p, r,D3DCOLOR_XRGB(255, 0, 0)); //PPhysicsShell()->XFORM().transform_tiny(c); Fmatrix mm; PPhysicsShell()->GetGlobalTransformDynamic(&mm); mm.transform_tiny(p,c); DBG_DrawAABB( p, r,D3DCOLOR_XRGB(0, 255, 0)); DBG_ClosedCashedDraw (50000); #endif spatial_move(); m_just_after_spawn = false; VERIFY(!OnServer()); PPhysicsShell()->get_ElementByStoreOrder(0)->Fix(); PPhysicsShell()->SetIgnoreStatic (); //PPhysicsShell()->SetIgnoreDynamic (); //PPhysicsShell()->DisableCollision(); } //CalculateInterpolationParams() };
BOOL CPhysicsShellHolder::net_Spawn (CSE_Abstract* DC) { CParticlesPlayer::net_SpawnParticles (); st_enable_state=(u8)stNotDefitnite; b_sheduled = true; BOOL ret=inherited::net_Spawn (DC);//load //create_physic_shell (); if(PPhysicsShell()&&PPhysicsShell()->isFullActive()) { PPhysicsShell()->GetGlobalTransformDynamic(&XFORM()); PPhysicsShell()->mXFORM = XFORM(); switch (EEnableState(st_enable_state)) { case stEnable : PPhysicsShell()->Enable() ;break; case stDisable : PPhysicsShell()->Disable() ;break; case stNotDefitnite : ;break; } ApplySpawnIniToPhysicShell(pSettings,PPhysicsShell(),false); st_enable_state=(u8)stNotDefitnite; } return ret; }
void CPhysicsShellHolder::correct_spawn_pos() { VERIFY (PPhysicsShell()); Fvector size; Fvector c; get_box (PPhysicsShell(),XFORM(),size,c); CPHActivationShape activation_shape; activation_shape.Create (c,size,this); activation_shape.set_rotation (XFORM()); PPhysicsShell()->DisableCollision (); activation_shape.Activate (size,1,1.f,M_PI/8.f); //// VERIFY (valid_pos(activation_shape.Position(),phBoundaries)); // if (!valid_pos(activation_shape.Position(),phBoundaries)) { // CPHActivationShape activation_shape; // activation_shape.Create (c,size,this); // activation_shape.set_rotation (XFORM()); // activation_shape.Activate (size,1,1.f,M_PI/8.f); //// VERIFY (valid_pos(activation_shape.Position(),phBoundaries)); // } PPhysicsShell()->EnableCollision (); Fvector ap = activation_shape.Position(); #ifdef DEBUG if (!valid_pos(ap,phBoundaries)) { Msg("not valid position %f,%f,%f",ap.x,ap.y,ap.z); Msg("size %f,%f,%f",size.x,size.y,size.z); Msg("Object: %s",Name()); Msg("Visual: %s",*(cNameVisual())); Msg("Object pos %f,%f,%f",Position().x,Position().y,Position().z); } #endif // DEBUG VERIFY (valid_pos(activation_shape.Position(),phBoundaries)); Fmatrix trans; trans.identity (); trans.c.sub (ap,c); PPhysicsShell()->TransformPosition (trans); PPhysicsShell()->GetGlobalTransformDynamic(&XFORM()); activation_shape.Destroy (); }
void CPhysicObject:: anim_time_set ( float time ) { if( !check_blend( m_anim_blend, cName().c_str(), cNameSect().c_str(), cNameVisual().c_str() ) ) return ; if( time < 0.f || time > m_anim_blend->timeTotal ) { #ifdef DEBUG Msg( " ! can not set blend time %f - it must be in range 0 - %f(timeTotal) obj: %s, model: %s, anim: %s", time, m_anim_blend->timeTotal, cName().c_str(), cNameVisual().c_str(), smart_cast<IKinematicsAnimated*>( PPhysicsShell()->PKinematics() )->LL_MotionDefName_dbg( m_anim_blend->motionID ).first ); #endif return; } m_anim_blend->timeCurrent = time; IKinematics *K = smart_cast<IKinematics*>(Visual()); VERIFY( K ); K->CalculateBones_Invalidate(); K->CalculateBones(TRUE); }
BOOL CHangingLamp::net_SaveRelevant () { return (inherited::net_SaveRelevant() || BOOL(PPhysicsShell()!=NULL)); }
void CArtefact::ForceTransform(const Fmatrix& m) { VERIFY( PPhysicsShell() ); XFORM().set(m); PPhysicsShell()->SetGlTransformDynamic( m );// XFORM().set(m); }
void CActorMP::net_Import ( NET_Packet &P) { net_update N; m_state_holder.read (P); R_ASSERT2(valid_pos(m_state_holder.state().position), "imported bad position"); /*if (m_i_am_dead) return;*/ if (OnClient()) { /*#ifdef DEBUG if (GetfHealth() != m_state_holder.state().health) Msg("net_Import: [%d][%s], is going to set health to %2.04f", this->ID(), Name(), m_state_holder.state().health); #endif*/ game_PlayerState* ps = Game().GetPlayerByGameID(this->object_id()); float new_health = m_state_holder.state().health; if (GetfHealth() < new_health) { SetfHealth(new_health); } else { if (!ps || !ps->testFlag(GAME_PLAYER_FLAG_INVINCIBLE)) { SetfHealth(new_health); } } } if (PPhysicsShell() != NULL) { return; } if (OnClient()) SetfRadiation (m_state_holder.state().radiation*100.0f); u16 ActiveSlot = m_state_holder.state().inventory_active_slot; if (OnClient() && (inventory().GetActiveSlot()!=ActiveSlot) ) { #ifdef DEBUG Msg("Client-SetActiveSlot[%d][%d]",ActiveSlot, Device.dwFrame); #endif // #ifdef DEBUG inventory().SetActiveSlot(ActiveSlot); } N.mstate = m_state_holder.state().body_state_flags; N.dwTimeStamp = m_state_holder.state().time; N.p_pos = m_state_holder.state().position; N.o_model = m_state_holder.state().model_yaw; N.o_torso.yaw = m_state_holder.state().camera_yaw; N.o_torso.pitch = m_state_holder.state().camera_pitch; N.o_torso.roll = m_state_holder.state().camera_roll; if (N.o_torso.roll > PI) N.o_torso.roll -= PI_MUL_2; { if (Level().IsDemoPlay() || OnServer() || Remote()) { unaffected_r_torso.yaw = N.o_torso.yaw; unaffected_r_torso.pitch = N.o_torso.pitch; unaffected_r_torso.roll = N.o_torso.roll; cam_Active()->yaw = -N.o_torso.yaw; cam_Active()->pitch = N.o_torso.pitch; }; }; //CSE_ALifeCreatureActor N.p_accel = m_state_holder.state().logic_acceleration; process_packet (N); net_update_A N_A; m_States.clear (); N_A.State.enabled = m_state_holder.state().physics_state_enabled; N_A.State.angular_vel = m_state_holder.state().physics_angular_velocity; N_A.State.linear_vel = m_state_holder.state().physics_linear_velocity; N_A.State.force = m_state_holder.state().physics_force; N_A.State.torque = m_state_holder.state().physics_torque; N_A.State.position = m_state_holder.state().physics_position; N_A.State.quaternion = m_state_holder.state().physics_quaternion; // interpolcation postprocess_packet (N_A); }
BOOL CBaseMonster::net_SaveRelevant () { return (inherited::net_SaveRelevant() || BOOL(PPhysicsShell()!=NULL)); }
void CInventoryItem::PH_A_CrPr () { if (m_just_after_spawn) { VERIFY(object().Visual()); IKinematics *K = object().Visual()->dcast_PKinematics(); VERIFY( K ); if (!object().PPhysicsShell()) { Msg("! ERROR: PhysicsShell is NULL, object [%s][%d]", object().cName().c_str(), object().ID()); VERIFY2(0, "physical shell is NULL"); return; } if(!object().PPhysicsShell()->isFullActive()) { K->CalculateBones_Invalidate(); K->CalculateBones(TRUE); } object().PPhysicsShell()->GetGlobalTransformDynamic(&object().XFORM()); K->CalculateBones_Invalidate(); K->CalculateBones(TRUE); #if 0 Fbox bb= BoundingBox (); DBG_OpenCashedDraw (); Fvector c,r,p; bb.get_CD(c,r ); XFORM().transform_tiny(p,c); DBG_DrawAABB( p, r,D3DCOLOR_XRGB(255, 0, 0)); //PPhysicsShell()->XFORM().transform_tiny(c); Fmatrix mm; PPhysicsShell()->GetGlobalTransformDynamic(&mm); mm.transform_tiny(p,c); DBG_DrawAABB( p, r,D3DCOLOR_XRGB(0, 255, 0)); DBG_ClosedCashedDraw (50000); #endif object().spatial_move(); m_just_after_spawn = false; VERIFY(!OnServer()); object().PPhysicsShell()->get_ElementByStoreOrder(0)->Fix(); object().PPhysicsShell()->SetIgnoreStatic (); //object().PPhysicsShell()->SetIgnoreDynamic (); //PPhysicsShell()->DisableCollision(); } /*net_updateData* p = NetSync(); //restore recalculated data and get data for interpolation if (!object().CrPr_IsActivated()) return; //////////////////////////////////// CPHSynchronize* pSyncObj = NULL; pSyncObj = object().PHGetSyncItem (0); if (!pSyncObj) return; //////////////////////////////////// pSyncObj->get_State (p->PredictedState); //////////////////////////////////// pSyncObj->set_State (p->RecalculatedState); //////////////////////////////////// if (!m_flags.test(FInInterpolate)) return; //////////////////////////////////// Fmatrix xformX; pSyncObj->cv2obj_Xfrom(p->PredictedState.quaternion, p->PredictedState.position, xformX); VERIFY2 (_valid(xformX),*object().cName()); pSyncObj->cv2obj_Xfrom (p->PredictedState.quaternion, p->PredictedState.position, xformX); p->IEndRot.set (xformX); p->IEndPos.set (xformX.c); VERIFY2 (_valid(p->IEndPos),*object().cName()); ///////////////////////////////////////////////////////////////////////// CalculateInterpolationParams (); ///////////////////////////////////////////////////*/ };
void CCar::Init() { CPHCollisionDamageReceiver::Init(); //get reference wheel radius IKinematics* pKinematics=smart_cast<IKinematics*>(Visual()); CInifile* ini = pKinematics->LL_UserData(); R_ASSERT2(ini,"Car has no description !!! See ActorEditor Object - UserData"); ///SWheel& ref_wheel=m_wheels_map.find(pKinematics->LL_BoneID(ini->r_string("car_definition","reference_wheel")))->second; if(ini->section_exist("air_resistance")) { PPhysicsShell()->SetAirResistance(default_k_l*ini->r_float("air_resistance","linear_factor"),default_k_w*ini->r_float("air_resistance","angular_factor")); } if(ini->line_exist("car_definition","steer")) { m_bone_steer=pKinematics->LL_BoneID(ini->r_string("car_definition","steer")); VERIFY2(fsimilar(DET(pKinematics->LL_GetTransform(m_bone_steer)),1.f,EPS_L),"BBADD MTX"); pKinematics->LL_GetBoneInstance(m_bone_steer).set_callback(bctPhysics,cb_Steer,this); } m_steer_angle=0.f; //ref_wheel.Init(); m_ref_radius=ini->r_float("car_definition","reference_radius");//ref_wheel.radius; b_exploded =false; b_engine_on =false; b_clutch =false; b_starting =false; b_stalling =false; b_transmission_switching =false; m_root_transform.set(bone_map.find(pKinematics->LL_GetBoneRoot())->second.element->mXFORM); m_current_transmission_num=0; m_pPhysicsShell->set_DynamicScales(1.f,1.f); CDamagableItem::Init(GetfHealth(),3); float l_time_to_explosion=READ_IF_EXISTS(ini,r_float,"car_definition","time_to_explosion",120.f); CDelayedActionFuse::Initialize(l_time_to_explosion,CDamagableItem::DamageLevelToHealth(2)); { xr_map<u16,SWheel>::iterator i,e; i=m_wheels_map.begin(); e=m_wheels_map.end(); for(;i!=e;++i) { i->second.Init(); i->second.CDamagableHealthItem::Init(100.f,2); } } { xr_vector<SWheelDrive>::iterator i,e; i=m_driving_wheels.begin(); e=m_driving_wheels.end(); for(;i!=e;++i) i->Init(); } { xr_vector<SWheelBreak>::iterator i,e; i=m_breaking_wheels.begin(); e=m_breaking_wheels.end(); for(;i!=e;++i) i->Init(); } { xr_vector<SWheelSteer>::iterator i,e; i=m_steering_wheels.begin(); e=m_steering_wheels.end(); for(;i!=e;++i) i->Init(); } { xr_vector<SExhaust>::iterator i,e; i=m_exhausts.begin(); e=m_exhausts.end(); for(;i!=e;++i) i->Init(); } { xr_map<u16,SDoor>::iterator i,e; i=m_doors.begin(); e=m_doors.end(); for(;i!=e;++i) { i->second.Init(); i->second.CDamagableHealthItem::Init(100,1); } } if(ini->section_exist("damage_items")) { CInifile::Sect& data = ini->r_section("damage_items"); for (CInifile::SectCIt I=data.Data.begin(); I!=data.Data.end(); I++){ const CInifile::Item& item = *I; u16 index = pKinematics->LL_BoneID(*item.first); R_ASSERT3(index != BI_NONE, "Wrong bone name", *item.first); xr_map <u16,SWheel>::iterator i=m_wheels_map.find(index); if(i!=m_wheels_map.end()) i->second.CDamagableHealthItem::Init(float(atof(*item.second)),2); else { xr_map <u16,SDoor>::iterator i=m_doors.find(index); R_ASSERT3(i!=m_doors.end(),"only wheel and doors bones allowed for damage defs",*item.first); i->second.CDamagableHealthItem::Init(float(atof(*item.second)),1); } } } if(ini->section_exist("immunities")) { LoadImmunities("immunities",ini); } CDamageManager::reload("car_definition","damage",ini); HandBreak(); Transmission(1); }