bool ETHRenderEntity::IsSpriteVisible(const ETHSceneProperties& sceneProps, const ETHBackBufferTargetManagerPtr& backBuffer) const { if (!m_pSprite || IsHidden()) return false; const float angle = GetAngle(); if (GetType() == ETHEntityProperties::ET_VERTICAL || angle == 0.0f) { const Vector2& bufferSize = backBuffer->GetBufferSize(); const ETHEntityProperties::VIEW_RECT& rect = GetScreenRect(sceneProps); const Vector2& min = rect.min; const Vector2& max = rect.max; if (min.x > bufferSize.x || min.y > bufferSize.y) { return false; } else if (max.x < 0.0f || max.y < 0.0f) { return false; } else { return true; } } else { // TODO/TO-DO perform this in the OrientedBoundingBox class const Vector2& size = GetCurrentSize(); const float radianAngle = -DegreeToRadian(angle); const OrientedBoundingBox entityObb(ComputeInScreenSpriteCenter(sceneProps), size, radianAngle); return entityObb.Overlaps(*(backBuffer->GetOBB().get())); } }
void ETHScene::MapEntitiesToBeRendered( float &minHeight, float &maxHeight, const ETHBackBufferTargetManagerPtr& backBuffer) { // store the max and min height to assign when everything is drawn maxHeight = m_maxSceneHeight; minHeight = m_minSceneHeight; m_nRenderedEntities = 0; const VideoPtr& video = m_provider->GetVideo(); // don't let bucket size equal to 0 assert(GetBucketSize().x != 0 || GetBucketSize().y != 0); // Gets the list of visible buckets std::list<Vector2> bucketList; const Vector2& camPos = video->GetCameraPos(); //for debugging purposes m_buckets.GetIntersectingBuckets(bucketList, camPos, backBuffer->GetBufferSize(), IsDrawingBorderBuckets(), IsDrawingBorderBuckets()); assert(m_activeEntityHandler.IsCallbackListEmpty()); // Loop through all visible Buckets for (std::list<Vector2>::iterator bucketPositionIter = bucketList.begin(); bucketPositionIter != bucketList.end(); ++bucketPositionIter) { ETHBucketMap::iterator bucketIter = m_buckets.Find(*bucketPositionIter); if (bucketIter == m_buckets.GetLastBucket()) continue; ETHEntityList& entityList = bucketIter->second; if (entityList.empty()) continue; ETHEntityList::const_iterator iEnd = entityList.end(); for (ETHEntityList::iterator iter = entityList.begin(); iter != iEnd; ++iter) { ETHRenderEntity *entity = (*iter); // update scene bounding for depth buffer maxHeight = Max(maxHeight, entity->GetMaxHeight()); minHeight = Min(minHeight, entity->GetMinHeight()); if (entity->IsHidden()) continue; // fill the callback list m_activeEntityHandler.AddStaticCallbackWhenEligible(entity); m_renderingManager.AddDecomposedPieces(entity, minHeight, maxHeight, backBuffer, m_sceneProps); m_nRenderedEntities++; } } // Add persistent entities (the ones the user wants to force to render) FillMultimapAndClearPersistenList(bucketList, backBuffer); m_nCurrentLights = m_renderingManager.GetNumLights(); }
void ETHGlobalScaleManager::SetSceneFixedWidthInScreen(const ETHBackBufferTargetManagerPtr& backBuffer, const float width) { m_scaleFactor = backBuffer->GetBufferSize().x / width; }
void ETHGlobalScaleManager::SetSceneFixedHeightInScreen(const ETHBackBufferTargetManagerPtr& backBuffer, const float height) { m_scaleFactor = backBuffer->GetBufferSize().y / height; }