void CSimpleEnemy::updateAnimationsCallback(const Ogre::Real fTime) { for (CWorldEntity *pEnt : dynamic_cast<CharacterControllerPhysics*>(mCCPhysics)->getCollidingWorldEntities()) { if (dynamic_cast<CCharacter*>(pEnt) && dynamic_cast<CCharacter*>(pEnt)->getFriendOrEnemyState() == FOE_FRIENDLY) { pEnt->hit(CDamage(DMG_SWORD, m_pSceneNode->getOrientation().zAxis())); } } CSimpleEnemyController::EKIState eKIState = dynamic_cast<CSimpleEnemyController*>(m_pCharacterController)->getCurrentKIState(); if (eKIState == CSimpleEnemyController::KI_PATROLING || eKIState == CSimpleEnemyController::KI_WALK_TO_PLAYER) { if (m_uiAnimID != SE_ANIM_WALK) { setAnimation(SE_ANIM_WALK, true); } } else if (eKIState == CSimpleEnemyController::KI_SCOUTING) { if (m_uiAnimID != SE_ANIM_SCOUT) { setAnimation(SE_ANIM_SCOUT, true); } } const Ogre::Vector3 vDir = m_pBodyEntity->getParentNode()->convertLocalToWorldOrientation(m_pBodyEntity->getSkeleton()->getBone(PERSON_RIGHT_HANDLE)->_getDerivedOrientation()).yAxis(); const Ogre::Vector3 vPos = m_pBodyEntity->getParentNode()->convertLocalToWorldPosition(m_pBodyEntity->getSkeleton()->getBone(PERSON_RIGHT_HANDLE)->_getDerivedPosition()); DebugDrawer::getSingleton().drawLine(vPos, vPos + vDir * 0.1, Ogre::ColourValue::Blue); createDamage(Ogre::Ray(vPos, vDir * 0.1), CDamage(DMG_SWORD, m_pSceneNode->getOrientation().zAxis())); }
void SwitcherPixmapItem::updateXWindowPixmap() { #ifdef Q_WS_X11 // It is possible that the window is not redirected so check for errors. // XSync() needs to be called so that previous errors go to the original // handler. X11Wrapper::XSync(QX11Info::display(), FALSE); XErrorHandler errh = X11Wrapper::XSetErrorHandler(handleXError); xErrorCode = Success; // Get the pixmap ID of the X window Pixmap newWindowPixmap = X11Wrapper::XCompositeNameWindowPixmap(QX11Info::display(), d->windowId); // XCompositeNameWindowPixmap doesn't wait for the server to reply, we'll // need to do it ourselves to catch the possible BadMatch X11Wrapper::XSync(QX11Info::display(), FALSE); d->xWindowPixmapIsValid = xErrorCode == Success; if (d->xWindowPixmapIsValid) { // Unregister the old pixmap from XDamage events destroyDamage(); if (d->xWindowPixmap != 0) { // Dereference the old pixmap ID X11Wrapper::XFreePixmap(QX11Info::display(), d->xWindowPixmap); } d->xWindowPixmap = newWindowPixmap; // Register the pixmap for XDamage events createDamage(); d->qWindowPixmap = QPixmap::fromX11Pixmap(d->xWindowPixmap, QPixmap::ExplicitlyShared); } else { // If a BadMatch error occurred the window wasn't redirected yet; deference the invalid pixmap if (newWindowPixmap != 0) { X11Wrapper::XFreePixmap(QX11Info::display(), newWindowPixmap); } } // Reset the error handler X11Wrapper::XSetErrorHandler(errh); #else #error "not implemented" #endif }