Ñò
ý�Pc           @   s  d  d k  Z  d  d k Z d  d k Z d  d k l Z d  d k l Z d  d k Td Z d Z d Z	 d Z
 d	 Z e
 e Z d
 Z d Z d Z d Z d Z e	 d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z d Z  d Z! d Z" d Z# d Z$ d Z% d Z& d Z' d Z( d Z) d Z* d Z+ d Z, d Z- d e Z. d e Z/ d Z0 d  Z1 d! Z2 d" Z3 d Z4 d# Z5 d$ Z6 d% Z7 d& Z8 d' Z9 d( Z: d) Z; d* Z< d+ Z= d, Z> d- Z? d. Z@ d/ ZA d0 ZB d1 ZC d2 ZD d3 ZE d ZF d' ZG d ZH d ZI d4 ZJ d ZK d ZL d ZM e o eN n eO ZP d ZQ d5 ZR d6 ZS d7 ZT d8 ZU d9 ZV d4 ZW d ZX d: ZY d; ZZ d Z[ d Z\ d Z] d Z^ d< Z_ d= Z` d> Za d? Zb d? Zc d@ Zd dA Ze dB Zf dC Zg d Zh d Zi d Zj dD Zk dE Zl dF Zm dG Zn d& Zo d Zp d Zq d Zr d Zs dH Zt dI Zu dJ Zv d Zw d Zx d Zy dK Zz dL Z{ dM Z| eN Z} d Z~ d0 Z d Z€ dN Z� dO Z‚ dP Zƒ eN Z„ eN Z… dJ Z† eO Z‡ dJ Zˆ g  Z‰ dQ „  ZŠ dR „  Z‹ dS „  ZŒ dT „  Z� dU „  ZŽ dV „  Z� dW „  Z� dX „  Z‘ dY „  Z’ dZ „  Z“ d[ „  Z” d\ „  Z• d] „  Z– d^ „  Z— d_ „  Z˜ d` „  Z™ da „  Zš d S(b   iÿÿÿÿN(   t   pi(   t	   IS_CLIENT(   t   *g…ëQ¸ž#@gÍÌÌÌÌÌô?gÍÌÌÌÌÌì?g      ô?gü©ñÒMbP?gìQ¸…ë±?g333333ã?gÍÌÌÌÌÌ@g333333&@gš™™™™™ñ?g      à?g      ð?g      ð¿g        g       @g      @g¨ÆK7‰Aì?i   gìQ¸…ë¡?g)\�Âõ(ä?g3333336@g333333ë?gš™™™™™©?g
×£p=
@gffffffÖ?g      @gffffffæ?gƒÀÊ¡E¶ë?gË¡E¶óýì?g      I@g      N@g)\�Âõ(ì?g      >@gš™™™™™á?gš™™™™™É?gš™™™™™é?g     €F@g     €V@g{®Gáz”?g¸…ëQ¸ž?gÃõ(\�Âí?gffffffò?gš™™™™™é¿g{®Gáz„?g333333Ó?g�Âõ(\�ö?g      ø?g      @g®Gázî?g
×£p=
ç?g      Ð?g5^ºIï?g…ëQ¸@g{®Gázt?g     @�@gÍÌÌÌÌÌ@g      @g      @i   g      @gš™™™™™É¿g      Ð¿g333333Ó¿g      #@g      *@g      5@g      ü?g{®Gázä?g{®Gáz´?gš™™™™™¹?gÃõ(\�Âµ?g¤p=
×£à?gyé&1¬¼?i
   i   i   c          C   s`   xA t  i i ƒ  D]0 }  |  i d j o t |  i i |  i ƒ q q Wx t D] } | ƒ  qK Wd  S(   Nt   Vehicle(	   t   BigWorldt   entitiest   valuest	   classNamet   initVehiclePhysicst   movert   physicst   typeDescriptort   g_confUpdaters(   t   et   updater(    (    s    scripts/common/physics_shared.pyt
   updateConfÎ   s      c         C   s@   | t  t } | | | | | d } |  | t | |  | S(   Ng      (@(   t   GRAVITY_FACTORt   Gt   ANG_ACCELERATION_TIME(   t   rotSpeedLimitt   masst   lengtht   widtht   enginePowert   mgt   inertia(    (    s    scripts/common/physics_shared.pyt   computeRotationalCohesion×   s    c   C      C   sø	  | i  } | i d i \ } } } | | d } | i | i d i } | i | i } | i d i \ }	 }
 } |
 d |	 d } |
 d |	 d } |
 d |	 d } | d t } | d } | d } t | | ƒ | } t o
 | } n | | } t t	 } | i d i | i t
 } t t | | t | ƒ } t | ƒ } t p | t | } n | | } | | } t | | ƒ } t i d	 | | | d	 f ƒ |  _ t } t o
 d	 } n/ |  i i | | } | t |  i i | } | i d i | i } | t | } | | d } t i d | |  i i d f ƒ } | d
 } t i t | | | | | | | | | | t | | | | | f ƒ }  t i | | | f ƒ }! t | | ƒ }" t i |! ƒ }# | |# _ |# i d }$ t i d	 |$ |  i i d	 f ƒ }% |  i |! | |# |% | |  ƒ | d \ }& }' |& |  _ |' |  _ t |  _ t |  _  | | |  _! | t" |  i i |  _# |  i# |  _$ t% t& |  i$ |  i# ƒ |  _' t i | | | d	 f ƒ |  _( t i | | | d	 f ƒ |  _) t* |  _+ | d |  _, | d }( | d t- |  _. t p> t/ t t0 t1 ƒ |  _2 t3 |  _4 t5 |  _6 t7 |  _8 t9 |  _: n |  i. |  _; |( | d d |  _< | d |  _= t> |  _? t@ |  _A tB |  _C tD |  _E tF |  _G tH |  _I tJ |  _K tL |  _M tN |  _O tP |  _Q tR |  _S tT |  _U tV |  _W tX |  _Y tZ |  _[ t\ |  _] t^ |  __ t` |  _a tb |  _c td |  _e tf |  _g th |  _i tj |  _k tl |  _m | |  _n t |  _o tp |  _q tr |  _s tt |  _u tv |  _w tx |  _y tz |  _{ d |  _| t i | | | d	 f ƒ |  _} t i | | | d	 f ƒ |  _~ t |( | | | |  i. ƒ }) |) |  _€ d |  _� |( d |  _‚ tƒ |  _„ t… |  _† d |  _‡ d |  _| tˆ |  _‰ tŠ |& |  _‹ tŒ |& |  _� tŽ |  _� |( t� |  _‘ |  i‘ t’ tŽ |  _“ | d }* t i” |* d |* d |* d |* d ƒ }+ |+ |  _• t– |  _— t˜ |  _™ tš d |  _› t0 |  _œ t� |  _ž tŸ |  _  t¡ |  _¢ t£ |  _¤ t¥ |  _¦ t§ |  _¨ |  i© ƒ  | | }, | tª j  o$ | t« j  p |, t¬ j  o
 t­ }- n t® }- | }. | |- d |. d | }/ t¯ | ƒ |/ }0 t° | | ƒ }1 | d }2 t i d ƒ }3 |1 |- d }4 |1 d }5 | d }6 | d }7 | d | i }8 | |- d }9 t i d ƒ }: |: }; t }< t± }= x-t² d |- ƒ D]}> |> d j p |> |- d j o t³ n d	 }? d	 d	 |> d j o d n d f }@ |3 |; i´ |@ ƒ }A t i |6 |8 |5 |> |4 f ƒ }B |  iµ |B |3 |; |. |2 |" |/ |0 |9 t¶ |< |= |? |A f ƒ |A }A t i |7 |8 |5 |> |4 f ƒ }B |  iµ |B |3 |: |. |2 |" |/ |0 |9 t· |< |= |? |A f ƒ qRWt¸ o{ t¹ d | | ƒ t¹ d t | | ƒ ƒ t¹ d |1 | ƒ t¹ d | | ƒ t¹ d |" ƒ t¹ d | ƒ t¹ d | ƒ n d  S(    Nt	   hitTesterg      à?t   hullPositioni   i    i   t   weightR   g        g      (@t   speedLimitst   rotationIsAroundCentert   rotationSpeedLimitt   terrainResistancet   trackCenterOffsetg      ð?gš™™™™™¹?i
   g       @iÿÿÿÿgÍÌÌÌÌÌÜ?g      ð¿s    initVehiclePhysics: clearance %fs   initVehiclePhysics: suspMass %fs   initVehiclePhysics: trackLen %fs%   initVehiclePhysics: clearanceRatio %fs    initVehiclePhysics: hardRatio %fs   initVehiclePhysics: cmShift %fs'   initVehiclePhysics: suspCompression: %f(   i    iÿÿÿÿi    (   i   i    i    (º   R
   t   hullt   bboxt   yt   chassist   WEIGHT_SCALEt   _computeSuspWeightRatioR   R   R   t	   CLEARANCEt   _clampt   CLEARANCE_MINt   CLEARANCE_MAXt   _computeSuspCompressiont   TRACKS_PENETRATIONt   _computeCenterOfMassShiftt   Matht   Vector3t   centerOfMasst   FORCE_POINT_Xt   FORCE_POINT_Yt   BODY_HEIGHTt   XIt   ZIt   _computeHardRatiot	   setupBodyt   fwdSpeedLimitt   bkwdSpeedLimitt   COHESIONt   brakeFrictiont   FORWARD_FRICTIONt   forwardFrictiont   sideFrictionXt   ROLL_TRACTION_MINt   sideFrictionYMint   sideFrictionYMaxt   ROLL_TRACTIONt   abst   sideFrictionYSpeedt   leftForcePtt   rightForcePtt   CENTER_ROTATION_SPEEDt   centerRotationSpeedR   t   GRAVITY_FACTOR_SCALEDR   t   mint   _COH_DECAY_BOUNDt   SLOPE_COH_DECAYt   slopeCohDecayt   SLOPE_COH_DECAY_Yt   slopeCohDecayYt   COH_DECAY_COMPENSATIONt   compensateFrictionDecayRatiot   COH_DECAY_COMPENSATION_Yt   compensateFrictionDecayYt   CONTACT_COHESIONt   contactCohesiont   normalEnginePowerR    R"   t   ROTATION_POWER_FACTORt   rotationPowerFactort   MIN_SIDE_FRICTIONt   minSideFrictiont   MIN_SIDE_FRICTION_SPEEDt   minSideFrictionSpeedt   MAX_SIDE_FRICTIONt   maxSideFrictiont   MAX_SIDE_FRICTION_SPEEDt   maxSideFrictionSpeedt   SIDE_FRICTION_SPEED_FACTORt   sideFrictionSpeedK1t   CONTACT_NORMAL_SIDE_FRICTIONt   contactNormalSideFrictiont   BEG_SLIP_POWERt   begSlipFrictionPowert   END_SLIP_POWERt   endSlipFrictionPowert   BEG_SLIP_SPEEDt   begSlipFrictionSpeedt   END_SLIP_SPEEDt   endSlipFrictionSpeedt   MIN_SLIP_FRICTIONt   minSlipFrictiont   MAX_SLIP_FRICTIONt   maxSlipFrictiont    FWD_CONTACT_SLIP_FRICTION_FACTORt   fwdContactSlipFrictionFactort   FWD_CONTACT_SLIP_FRICTION_POWt   fwdContactSlipFrictionPowt   FWD_CONTACT_SLIP_FRICTION_MAXt   fwdContactSlipFrictionMaxt   FWD_SLIP_FRICTION_FACTORt   fwdSlipFrictionFactort   FWD_SLIP_FRICTION_POWt   fwdSlipFrictionPowt   FWD_SLIP_FRICTION_MAXt   fwdSlipFrictionMaxt   BROKEN_TRACK_SIDE_FRICTIONt   brokenTrackSideFrictiont   BROKEN_TRACK_FWD_FRICTIONt   brokenTrackFwdFrictiont   BROKEN_TRACK_ROT_FRICTION_MPt   brokenTrackRotFrictionMPt   ROTATION_POWER_FRACTIONt   rotationPowerFractiont   BKWD_POWER_FRACTIONt   bkwdPowerFractiont   gravityt   cohesiont   RISE_FRICTIONt   riseFrictiont   RISE_FRICTION_Yt   riseFrictionYt   SUSP_SLUMP_FRICTIONt   suspSlumpFrictiont   SUSP_SLUMP_FRICTION_BOUNDt   slumpFrictionBoundt   FWD_FRICTION_Yt   fwdWrictionYt   MAX_SLIP_FRICTION_Yt   maxSlipFrictionYt   movementSignalst   leftFwdFrictionPtt   rightFwdFrictionPtR   t   rotationalCohesiont   linMinPowerDividert   rotMinPowerDividert   TRACK_SIDE_FRICTIONt   springsHardFrictiont   TRACK_FWD_FRICTIONt   springFwdFrictiont   destructibleDamageFactort   TRACK_RESTITUTIONt   tracksRestitutiont   CONTINUUM_RESIST_SPEEDt   continuumResistSpeedt   CONTINUUM_RESISTt   continuumResistt   MIN_SPEED_AFFECT_ROTt   minSpeedAffectRott   SPEED_AFFECT_ROT_DECREASEt   speedAffectRotBoundt   MAX_SPEED_AFFECT_ROTt   speedAffectRott   Vector4t   groundResistancest   _COH_DECAY_Yt	   cohDecayYt   _COH_DECAY_FACTORt   cohDecayFactort   _COH_DECAY_POWt   cohDecayPowt   cohDecayBoundt   _STRAFE_THRESHOLDt   strafeThresholdt   FREEZE_ACCEL_EPSILONt   freezeAccelEpsilont   FREEZE_ANG_ACCEL_EPSILONt   freezeAngAccelEpsilont   FREEZE_VEL_EPSILONt   freezeVelEpsilont   FREEZE_ANG_VEL_EPSILONt   freezeAngVelEpsilont   _SIMULATION_Y_BOUNDt   simulationYBoundt   removeAllDamperSpringst   WIDTH_VERY_LONGt
   WIDTH_LONGt   CLEARANCE_RATIO_LONGt   NUM_SPRINGS_NORMALt   NUM_SPRINGS_LONGt   _computeSuspDampt   _computeTrackLengtht   ROLLER_MODEt   xranget   SUSP_CLIMB_FRICTIONt   dott   addDamperSpringt   Truet   Falset   _LOG_INIT_PARAMSt	   LOG_DEBUG(C   R
   t   typeDesct	   physDescrt   hullMint   hullMaxt   _t
   hullCentert   hullYt
   hullHeightt   bmint   bmaxt   blenR   t   heightt   fullMasst   srcEnginePowert   srcMasst   suspMasst   hullMasst   gt	   clearancet   suspCompressiont   carringSpringLengtht   hmgt   cmShiftt   forcePtXt   forcePtYt   hullUpperBoundt	   boxHeightt
   globalBoxYt	   boxCentert   impR   t   boxSizet	   hardRatiot   boxSize2t   globalBox2Yt
   boxCenter2R:   R;   t   wlimt   coht   terrResR¯   t   clearanceRatiot   carrierSpringPairsR   t	   stiffnesst   suspDampt   trackLent   indentt   sdirt   stepZt   begZt   leftXt   rightXR%   t
   rollerMasst   rsidet   lsidet   pent
   rollerModet   it   climbFrictiont   climbDirAxist   climbFrictionDirt
   mountPoint(    (    s    scripts/common/physics_shared.pyR   Þ   s˜   	






#
"
 	"				 	
																																				 								
(										

'


 +# 
 c         C   s�   |  i  d i d d } t i ƒ  } | i | ƒ | i d d | f ƒ |  i d } | i | ƒ | i | ƒ } | |  i d |  i	 7} | |  i
 d 7} | S(   NR   i   i   g        t   gunPositiont   turretPositionsR   (   t   gunR$   R0   t   Matrixt
   setRotateXt   applyVectort   turrett
   setRotateYR#   t   activeTurretPositionR&   (   t   vehDescrt	   turretYawt   gunPitcht   maxGunZt   mt   pt(    (    s    scripts/common/physics_shared.pyt   computeBarrelLocalPointá  s    #c         C   s"   t  d | >d |  t t d ƒ S(   Ni   g       @(   t   intR    (   t   anglet   bits(    (    s    scripts/common/physics_shared.pyt   encodeAngleToUintî  s    c         C   s   t  d |  d | >d t  S(   Ng       @i   (   R    (   t   codeR!  (    (    s    scripts/common/physics_shared.pyt   decodeAngleFromUintó  s    c   	      C   sF   | | } |  | | } t  d | d ƒ } | | } | | | } | S(   Ng        g      ð?(   R*   (	   t   argt   argMint   argMaxt   valMint   valMaxt   argRanget   nargt   valRanget   val(    (    s    scripts/common/physics_shared.pyt   linearInterpolate÷  s    

c         C   s:   |  t  t t  } t d | d ƒ } | t t t } | S(   Ng        g      ð?(   t   SUSP_DAMP_MASS_MINt   SUSP_DAMP_MASS_MAXR*   t   SUSP_DAMP_MAXt   SUSP_DAMP_MIN(   R   t   kt   damp(    (    s    scripts/common/physics_shared.pyRÉ     s    c         C   s,   | |  } t  | t t t t t t ƒ } | S(   N(   t   _powerCurvet   DYN_RATIO_MINt   DYN_RATIO_MIDt   DYN_RATIO_MAXt   CMY_MINt   CMY_MIDt   CMY_MAX(   R   R   t   drt   cmy(    (    s    scripts/common/physics_shared.pyR/   	  s    
	c         C   s,   | |  } t  | t t t t t t ƒ } | S(   N(   R5  R6  R7  R8  t   SUSP_WEIGHT_MINt   SUSP_WEIGHT_MIDt   SUSP_WEIGHT_MAX(   R   R   R<  t   swRatio(    (    s    scripts/common/physics_shared.pyR(     s    
	c         C   s   t  |  t t t t ƒ } | S(   N(   R.  t   SUSP_COMPRESSION_MIN_MASSt   SUSP_COMPRESSION_MAX_MASSt   SUSP_COMPRESSION_MINt   SUSP_COMPRESSION_MAX(   R   Rç   (    (    s    scripts/common/physics_shared.pyR-   %  s    	c         C   s*   |  | } t  | t t t t ƒ } | | S(   N(   R.  t   CLEARANCE_TO_LENGTH_MINt   CLEARANCE_TO_LENGTH_MAXt   TRACK_LENGTH_MAXt   TRACK_LENGTH_MIN(   Ræ   R   t   rt   lenRatio(    (    s    scripts/common/physics_shared.pyRÊ   0  s    
	c         C   s    |  | } t  | t t t t ƒ S(   N(   R.  RF  RG  t   HARD_RATIO_MINt   HARD_RATIO_MAX(   Ræ   R   RJ  (    (    s    scripts/common/physics_shared.pyR8   <  s    
c         C   s†   | | } |  | | } t  d | d ƒ } | | | }	 | | }
 | | |
 } t i | |	 ƒ } t i | | ƒ } | |
 | } | S(   Ng        g      ð?(   R*   t   matht   logt   pow(   R%  R&  t   argMidR'  R(  t   valMidR)  R*  R+  t   nargMidR,  t   nvalMidRP  t   nvalR-  (    (    s    scripts/common/physics_shared.pyR5  F  s    

c         C   s   t  |  t | | ƒ ƒ S(   N(   t   maxRL   (   t   minBoundR%  t   maxBound(    (    s    scripts/common/physics_shared.pyR*   W  s    c   
      C   sè   |  i  } | i i \ } } | i } t d „  | i | Dƒ ƒ } | i | i d d ƒ } t d „  | i d Dƒ ƒ } | i | i d d ƒ } | d @d >}	 |	 | d @d	 >O}	 |	 | d
 @d >O}	 |	 | d @d >O}	 |	 | d
 @O}	 |	 S(   Nc         s   s!   x |  ] } | d  d Vq Wd S(   t   idi   N(    (   t   .0t   desc(    (    s    scripts/common/physics_shared.pys	   <genexpr>_  s   	 RY  i   c         s   s!   x |  ] } | d  d Vq Wd S(   RY  i   N(    (   RZ  R[  (    (    s    scripts/common/physics_shared.pys	   <genexpr>a  s   	 t   gunsi   i   iÿÿ  i   i   i   i   (	   R   t   typeRY  R  t   tuplet   turretst   indexR  R  (
   t   vehiclet	   typeDescrt   nationIDt   vehIDt	   turretPost
   turretIdxst	   turretIdxt   gunIdxst   gunIdxt   descr(    (    s    scripts/common/physics_shared.pyt   _encodeTurretDescr[  s    		c         C   sU   |  d ?d @} |  d ?d @} |  d ?d @} |  d ?d @} |  d @} | | | | | f S(   Ni   i   i   iÿÿ  i   i   i   (    (   Rj  Rc  Rd  Re  Rg  Ri  (    (    s    scripts/common/physics_shared.pyt   _decodeTurretDescrm  s    
(›   R   R0   RN  R    t	   constantsR   t   debug_utilsR   R<   RV   R   R'   RK   R>   R[   R]   R_   Ra   Re   Rc   Rg   Ri   Rk   Rm   Ro   Rq   R•   Rs   Ru   Rw   Ry   R{   R}   R¤   R¦   t   SUSP_WEIGHTR¨   R¬   Rª   R…   R‡   R   RY   RD   RA   t   ROLL_TRACTION_MAXR   R�   Rƒ   t   BROKEN_TRACK_YR�   R‹   RD  RB  RE  RC  t   SUSP_HARD_RATIOt   SUSP_INDENTRÍ   R/  R0  R2  R1  t   COLLBOX_2_EXPANDR5   t   CENTER_OF_MASS_YR.   R¢   R“   t   LIFT_SPRING_STIFFNESSt   LIFT_SPRING_SIZEt   SUSP_SOFT_FRICTIONRŸ   R�   R�   R‘   R3   R4   RÑ   RÐ   RË   RR   RT   RP   RN   R°   R²   R´   RM   R·   RÁ   R»   R¹   R½   R¿   RÅ   RÄ   RÆ   RÈ   RÇ   RI   R9  R:  R;  R>  R?  R@  R6  R7  R8  R)   R+   R,   t   STIFF_MPt   TRACK_LENGTH_FACTORRI  RH  t   CLEARANCE_TO_LENGTH_MIN2t   CLEARANCE_TO_LENGTH_MAX2R6   R7   RL  RF  RM  RG  RÒ   t   RESTITUTIONt   ALLOWED_PENETRATIONt   FRICTION_RATIOt   NUM_ITERATIONSt   MID_SOLVING_ITERATIONSt   NUM_SUBSTEPSt   WARMSTARTING_VEHICLE_VEHICLEt   WARMSTARTING_VEHICLE_STATICSt   WARMSTARTING_THRESHOLDt   USE_PSEUDO_CONTACTSt   CONTACT_PENETRATIONR   R   R   R   R  R"  R$  R.  RÉ   R/   R(   R-   RÊ   R8   R5  R*   Rk  Rl  (    (    (    s    scripts/common/physics_shared.pyt   <module>   s0  




				ÿ 										
			