void DynamicEntityNode::DynamicMove(sf::Vector2f Disp, bool SweepBothDirections) { unsigned int CollisionMask = eCollisionGroup::Monster | eCollisionGroup::Static | eCollisionGroup::Player | eCollisionGroup::Pickup; float SweepTmax = 1.5f; if (SweepBothDirections) { if (Disp.x != 0.0f) { HitInfo Hit; GetWorld()->GetQuadTree()->SweepShapeClosest(*GetCollisionShape(), GetWorldTransform(), sf::Vector2f(Disp.x, 0.0f), SweepTmax, CollisionMask, this, Hit); if (Hit.m_pObject) { Disp.x = 0.0f; OnTouch(Hit.m_pObject); } } if (Disp.y != 0.0f) { HitInfo Hit; GetWorld()->GetQuadTree()->SweepShapeClosest(*GetCollisionShape(), GetWorldTransform(), sf::Vector2f(0.0f, Disp.y), SweepTmax, CollisionMask, this, Hit); if (Hit.m_pObject) { Disp.y = 0.0f; OnTouch(Hit.m_pObject); } } } else { HitInfo Hit; GetWorld()->GetQuadTree()->SweepShapeClosest(*GetCollisionShape(), GetWorldTransform(), Disp, SweepTmax, CollisionMask, this, Hit); if (Hit.m_pObject) { Disp.x = 0.0f; Disp.y = 0.0f; OnTouch(Hit.m_pObject); } } Move(Disp); }
//============================================================================= // eControl::paintEvent //----------------------------------------------------------------------------- bool eControl::event(QEvent* event) { switch(event->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseMove: { QMouseEvent* me = (QMouseEvent*)event; bool ok = event->type() == QEvent::MouseMove ? ((me->buttons() & Qt::LeftButton) != 0) : (me->button() == Qt::LeftButton); if(ok) { float x = float(me->x())/width(); float y = float(me->y())/height(); OnTouch(x, y, event->type() != QEvent::MouseButtonRelease, 0); return true; } } return true; case QEvent::TouchBegin: case QEvent::TouchUpdate: case QEvent::TouchEnd: { QTouchEvent* te = (QTouchEvent*)event; foreach(const QTouchEvent::TouchPoint& p, te->touchPoints()) { float x = p.pos().x()/width(); float y = p.pos().x()/height(); OnTouch(x, y, p.state() != Qt::TouchPointReleased, p.id()); } } return true; default: return QWidget::event(event); } }
void CDHLProjectile::ReceiveMessage( int classID, bf_read &msg ) { if ( classID != GetClientClass()->m_ClassID ) { // message is for subclass BaseClass::ReceiveMessage( classID, msg ); return; } int iType = msg.ReadByte(); //Server is letting us know that we're about to be deleted if ( iType == MSG_NOTIFY_REMOVAL ) { if ( !m_bCollided ) { Vector vecDir = vec3_origin; if ( GetAbsVelocity() != vec3_origin ) vecDir = GetAbsVelocity(); else vecDir = m_vecProjectileVelocity; VectorNormalize( vecDir ); Vector vecStartPos = GetMoveType() == MOVETYPE_CUSTOM ? GetLocalOrigin() : m_vecProjectileOrigin; //Try to plant a decal trace_t decaltr; UTIL_TraceLine( vecStartPos, vecStartPos + (vecDir * 120.0), MASK_SHOT, this, //Pretty long distance, but seems necessary in practice COLLISION_GROUP_NONE, &decaltr ); //DebugDrawLine( decaltr.startpos, decaltr.endpos, 255, 0, 0, false, 3.0f ); if ( decaltr.DidHit() ) { OnTouch( decaltr, true ); } m_bCollided = true; } } }
/* ** =================================================================== ** Event : TCHS1_OnEvent (module Events) ** ** Component : TCHS1 [TouchScreen] ** Description : ** Event called touch screen events, like touched, untouched ** etc. ** Parameters : ** NAME - DESCRIPTION ** event - ** x - x coordinate ** y - y coordinate ** Returns : Nothing ** =================================================================== */ void TCHS1_OnEvent(TCHS1_TouchScreenEvent event, TCHS1_PixelDim x, TCHS1_PixelDim y) { OnTouch(event, x, y); }
void CDHLProjectile::PhysicsSimulate( void ) { //------------------------------------------------------------------------------- //Our own movement/physics simulation! //------------------------------------------------------------------------------- #ifdef CLIENT_DLL if ( m_bCollided ) return; if ( !m_pShooter && m_hShooter ) m_pShooter = m_hShooter.Get(); #else if ( m_flRemoveAt > 0.0f ) { if ( m_flRemoveAt < gpGlobals->curtime ) { m_flRemoveAt = 0.0f; SUB_Remove(); } return; } if ( IsMarkedForDeletion() ) return; #endif float flFrametime = gpGlobals->frametime; //Scale for slow motion if ( DHLRules() ) { if ( (m_iType == DHL_PROJECTILE_TYPE_BULLET || m_iType == DHL_PROJECTILE_TYPE_PELLET) ) flFrametime *= (dhl_bulletspeed.GetFloat() * DHLRules()->GetTimescale()); else if ( m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE ) flFrametime *= (dhl_knifespeed.GetFloat() * DHLRules()->GetTimescale()); else flFrametime *= DHLRules()->GetTimescale(); } Vector vecDir = vec3_origin; #ifndef CLIENT_DLL Vector vecStartPos = m_vecCurPosition; //This is where we are Vector vecEndPos = m_vecCurPosition; //This is where we're going Vector vecVelocity = m_vecCurVelocity; //Velocity #else Vector vecStartPos = GetLocalOrigin(); //This is where we are Vector vecEndPos = GetLocalOrigin(); //This is where we're going Vector vecVelocity = GetLocalVelocity(); //Velocity #endif //Find out where we should move to if ( vecVelocity != vec3_origin ) { static ConVarRef gravVar( "sv_gravity" ); //Gravity float newZVelocity = vecVelocity.z - ( flFrametime * gravVar.GetFloat() * GetGravity() ); vecVelocity.z = ( (vecVelocity.z + newZVelocity) / 2 ); vecDir = vecVelocity; VectorNormalize( vecDir ); //Gravity needs to be cumulative #ifndef CLIENT_DLL m_vecCurVelocity = vecVelocity; #else SetLocalVelocity( vecVelocity ); #endif vecVelocity *= flFrametime; vecEndPos = vecStartPos + vecVelocity; if ( vecEndPos.IsValid() ) { CTraceFilterSkipTwoEntities movetrfilter( this, m_pShooter, COLLISION_GROUP_NONE ); trace_t movetr; UTIL_TraceLine( vecStartPos, vecEndPos, MASK_SHOT, &movetrfilter, &movetr ); #ifndef CLIENT_DLL //Trace to triggers so we can hit surf glass and such CTakeDamageInfo triggerInfo( this, GetOwnerEntity(), m_iDamage, DMG_BULLET ); if ( m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE ) { //CalculateMeleeDamageForce( &triggerInfo, vecDir, movetr.endpos, 0.7f ); Vector vecForce = vecDir; VectorNormalize( vecForce ); //vecForce *= 10.0f; triggerInfo.SetDamageForce( vecForce ); } else CalculateBulletDamageForce( &triggerInfo, m_iAmmoType, vecDir, movetr.endpos, 1.0f ); triggerInfo.SetDamagePosition( movetr.endpos ); TraceAttackToTriggers( triggerInfo, movetr.startpos, movetr.endpos, vecDir ); #else //Hit ragdolls on the client CBaseEntity* pEnt = DHL_FX_AffectRagdolls( movetr.endpos, movetr.startpos, DMG_BULLET, &m_RagdollHitList ); //Keep track of ones we've hit if ( pEnt ) m_RagdollHitList.AddToTail( pEnt ); #endif if ( movetr.DidHit() ) if ( OnTouch( movetr, false, &movetrfilter ) ) return; MoveProjectileToPosition( vecEndPos ); m_flDistanceTravelled += vecEndPos.DistTo( vecStartPos ); #ifndef CLIENT_DLL //On rare occasions the projectile likes to fly right through the world and keep going forever, causing a memory leak if ( m_flDistanceTravelled > MAX_TRACE_LENGTH ) { SUB_Remove(); //SetThink( &CDHLProjectile::SUB_Remove ); //SetNextThink( gpGlobals->curtime + 0.1 ); } #endif } //Simulate Angles //QAngle angles; #ifdef CLIENT_DLL QAngle angles = GetLocalAngles(); //VectorAngles( vecDir, angles ); //angles.z = GetLocalAngles().z; //Vector conversion loses z QAngle angVel = GetLocalAngularVelocity(); angles += angVel * flFrametime; SetLocalAngles( angles ); SetNetworkAngles( angles ); #endif } }
LRESULT WindowImplBase::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lRes = 0; BOOL bHandled = TRUE; CPoint pt; switch (uMsg) { case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break; case WM_CLOSE: lRes = OnClose(uMsg, wParam, lParam, bHandled); break; case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break; #if defined(WIN32) && !defined(UNDER_CE) case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break; case WM_NCCALCSIZE: lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break; case WM_NCPAINT: lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break; case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break; case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break; case WM_MOUSEWHEEL: { pt.x = GET_X_LPARAM( lParam ); pt.y = GET_Y_LPARAM( lParam ); lRes = OnMouseWheel(uMsg,GET_KEYSTATE_WPARAM(wParam),GET_WHEEL_DELTA_WPARAM(wParam),pt,bHandled); break; } #endif case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break; case WM_CHAR: lRes = OnChar(uMsg, wParam, lParam, bHandled); break; case WM_SYSCOMMAND: lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); break; case WM_KEYDOWN: { lRes = OnKeyDown( uMsg,wParam, lParam&0xff, lParam>>16 ,bHandled); break; } case WM_KEYUP: { lRes = OnKeyUp(uMsg, wParam, lParam&0xff, lParam>>16,bHandled ); break; } case WM_SYSKEYDOWN: { lRes=OnSysKeyDown(uMsg,wParam,lParam&0xff,lParam>>16,bHandled); break; } case WM_SYSKEYUP: { lRes=OnSysKeyUp(uMsg,wParam,lParam&0xff,lParam>>16,bHandled); break; } case WM_KILLFOCUS: lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); break; case WM_SETFOCUS: lRes = OnSetFocus(uMsg, wParam, lParam, bHandled); break; case WM_LBUTTONUP: lRes = OnLButtonUp(uMsg, wParam, lParam, bHandled); break; case WM_LBUTTONDOWN: lRes = OnLButtonDown(uMsg, wParam, lParam, bHandled); break; case WM_RBUTTONDOWN: { lRes = OnRButtonDown(uMsg,wParam,lParam,bHandled); break; } case WM_RBUTTONUP: { lRes = OnRButtonUp(uMsg,wParam,lParam,bHandled); break; } case WM_MOUSEMOVE: { pt.x = GET_X_LPARAM( lParam ); pt.y = GET_Y_LPARAM( lParam ); lRes = OnMouseMove(uMsg, wParam, pt, bHandled); break; } case WM_MOUSEHOVER: { lRes = OnMouseHover(uMsg, wParam, lParam, bHandled); break; } #if(WINVER >= 0x0601) case WM_TOUCH: { UINT cInputs = LOWORD(wParam); HTOUCHINPUT hTouchInput=(HTOUCHINPUT)lParam; lRes = OnTouch(uMsg, cInputs, hTouchInput, bHandled); //If the application does not process the message, it must call DefWindowProc if (lRes==FALSE) { ::DefWindowProc(*this,uMsg,wParam,lParam); } break; } #endif #if(WINVER >= 0x0602) case WM_POINTERUP: { lRes = OnPointerUp(uMsg,wParam,lParam,bHandled); break; } case WM_POINTERDOWN: { lRes = OnPointerDown(uMsg,wParam,lParam,bHandled); break; } #endif default: { bHandled = FALSE; break; } } if (bHandled) { return lRes; } lRes = HandleCustomMessage(uMsg, wParam, lParam, bHandled); if(bHandled) { return lRes; } if (m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes)) { return lRes; } return CWindowWnd::HandleMessage(uMsg, wParam, lParam); }