<commit_before>// For conditions of distribution and use, see copyright notice in LICENSE

#pragma once

#include "CoreDefines.h"
#include "OgreModuleApi.h"
#include "OgreModuleFwd.h"
#include "SceneFwd.h"
#include "Math/MathFwd.h"
#include "IRenderer.h"
#include "Color.h"

#include <QObject>
#include <QList>

#include <set>

class Framework;
class DebugLines;
class Transform;

class QRect;

/// Contains the Ogre representation of a scene, ie. the Ogre Scene
class OGRE_MODULE_API OgreWorld : public QObject, public enable_shared_from_this<OgreWorld>
{
    Q_OBJECT

public:
    /// Called by the OgreRenderingModule upon the creation of a new scene
    OgreWorld(OgreRenderer::Renderer* renderer, ScenePtr scene);
    /// Fully destroys the Ogre scene
    virtual ~OgreWorld();

    /// Dynamic scene property name "ogre"
    static const char* PropertyName() { return "ogre"; }

    /// Returns an unique name to create Ogre objects that require a mandatory name. Calls the parent Renderer
    /** @param prefix Prefix for the name. */
    std::string GenerateUniqueObjectName(const std::string &prefix);

    /// Dump the debug geometry drawn this frame to the debug geometry vertex buffer. Called by Renderer before rendering.
    void FlushDebugGeometry();

    /// The default color used as ambient light for Ogre's SceneManager.
    static Color DefaultSceneAmbientLightColor();

    /// Sets scene fog to default ineffective settings, which plays nice with the SuperShader.
    /** Use this if you have altered the Ogre SceneManager's fog and want to reset it. */
    void SetDefaultSceneFog();

    std::string GetUniqueObjectName(const std::string &prefix) { return GenerateUniqueObjectName(prefix); } /**< @deprecated Use GenerateUniqueObjectName @todo Add warning print */

public slots:
    /// Does raycast into the world from viewport coordinates, using specific selection layer(s)
    /** The coordinates are a position in the render window, not scaled to [0,1].
        @param x Horizontal position for the origin of the ray
        @param y Vertical position for the origin of the ray
        @param layerMask Which selection layer(s) to use (bitmask)
        @return Raycast result structure, *never* a null pointer, use RaycastResult::entity to see if raycast hit something. */
    RaycastResult* Raycast(int x, int y, unsigned layerMask);
    /// @overload
    /** Does raycast into the world from viewport coordinates, using all selection layers
        @param x Horizontal position for the origin of the ray
        @param y Vertical position for the origin of the ray */
    RaycastResult* Raycast(int x, int y);
    /// @overload
    /** Does raycast into the world using a ray in world space coordinates. */
    RaycastResult* Raycast(const Ray& ray, unsigned layerMask);

    /// Does a frustum query to the world from viewport coordinates.
    /** @param viewRect The query rectangle in 2d window coords.
        @return List of entities within the frustrum. */
    QList<Entity*> FrustumQuery(QRect &viewRect) const;

    /// Returns whether a single entity is visible in the currently active camera
    bool IsEntityVisible(Entity* entity) const;
    
    /// Returns visible entities in the currently active camera
    QList<Entity*> VisibleEntities() const;
    
    /// Returns  whether the currently active camera is in this scene
    bool IsActive() const;
    
    /// Start tracking an entity's visibility within this scene, using any camera(s)
    /** After this, connect either to the EntityEnterView and EntityLeaveView signals,
        or the entity's EnterView & LeaveView signals, to be notified of the visibility change(s). */
    void StartViewTracking(Entity* entity);
    
    /// Stop tracking an entity's visibility
    void StopViewTracking(Entity* entity);
    
    /// Returns the Renderer instance
    OgreRenderer::Renderer* Renderer() const { return renderer_; }

    /// Returns the Ogre scene manager
    Ogre::SceneManager* OgreSceneManager() const { return sceneManager_; }

    /// Returns the parent scene<commit_msg>Add OgreWorld::Raycast convenience overloads that take in QPoint.<commit_after>// For conditions of distribution and use, see copyright notice in LICENSE

#pragma once

#include "CoreDefines.h"
#include "OgreModuleApi.h"
#include "OgreModuleFwd.h"
#include "SceneFwd.h"
#include "Math/MathFwd.h"
#include "IRenderer.h"
#include "Color.h"

#include <QObject>
#include <QList>

#include <set>

class Framework;
class DebugLines;
class Transform;

class QRect;

/// Contains the Ogre representation of a scene, ie. the Ogre Scene
class OGRE_MODULE_API OgreWorld : public QObject, public enable_shared_from_this<OgreWorld>
{
    Q_OBJECT

public:
    /// Called by the OgreRenderingModule upon the creation of a new scene
    OgreWorld(OgreRenderer::Renderer* renderer, ScenePtr scene);
    /// Fully destroys the Ogre scene
    virtual ~OgreWorld();

    /// Dynamic scene property name "ogre"
    static const char* PropertyName() { return "ogre"; }

    /// Returns an unique name to create Ogre objects that require a mandatory name. Calls the parent Renderer
    /** @param prefix Prefix for the name. */
    std::string GenerateUniqueObjectName(const std::string &prefix);

    /// Dump the debug geometry drawn this frame to the debug geometry vertex buffer. Called by Renderer before rendering.
    void FlushDebugGeometry();

    /// The default color used as ambient light for Ogre's SceneManager.
    static Color DefaultSceneAmbientLightColor();

    /// Sets scene fog to default ineffective settings, which plays nice with the SuperShader.
    /** Use this if you have altered the Ogre SceneManager's fog and want to reset it. */
    void SetDefaultSceneFog();

    std::string GetUniqueObjectName(const std::string &prefix) { return GenerateUniqueObjectName(prefix); } /**< @deprecated Use GenerateUniqueObjectName @todo Add warning print */

public slots:
    /// Does a raycast into the world from screen coordinates, using specific selection layer(s)
    /** @note The coordinates are screen positions, not viewport positions [0,1].
        @param x Horizontal screen position for the origin of the ray
        @param y Vertical screen position for the origin of the ray
        @param layerMask Which selection layer(s) to use (bitmask)
        @return Raycast result structure, *never* a null pointer, use RaycastResult::entity to see if raycast hit something. */
    RaycastResult* Raycast(int x, int y, unsigned layerMask);
    RaycastResult* Raycast(const QPoint &point, unsigned layerMask) { return Raycast(point.x(), point.y(), layerMask);} /**< @overload @param point Screen point. */
    /// @overload
    /** Does a raycast into the world from screen coordinates, using all selection layers */
    RaycastResult* Raycast(int x, int y);
    RaycastResult* Raycast(const QPoint &point) { return Raycast(point.x(), point.y());} /**< @overload @param point Screen point. */
    /// @overload
    /** Does raycast into the world using a ray in world space coordinates. */
    RaycastResult* Raycast(const Ray& ray, unsigned layerMask);

    /// @todo Add Raycast overloads which take max distance param.
    /// @todo Add RaycastAll which returns list of all hits

    /// Does a frustum query to the world from viewport coordinates.
    /** @param viewRect The query rectangle in 2d window coords.
        @return List of entities within the frustrum. */
    QList<Entity*> FrustumQuery(QRect &viewRect) const;

    /// Returns whether a single entity is visible in the currently active camera
    bool IsEntityVisible(Entity* entity) const;
    
    /// Returns visible entities in the currently active camera
    QList<Entity*> VisibleEntities() const;
    
    /// Returns  whether the currently active camera is in this scene
    bool IsActive() const;
    
    /// Start tracking an entity's visibility within this scene, using any camera(s)
    /** After this, connect either to the EntityEnterView and EntityLeaveView signals,
        or the entity's EnterView & LeaveView signals, to be notified of the visibility change(s). */
    void StartViewTracking(Entity* entity);
    
    /// Stop tracking an entity's visibility
    void StopViewTracking(Entity* entity);
    
    /// Returns the Renderer instance
    OgreRenderer::Renderer* Renderer() const { return renderer_; }

    /// Returns the Ogre scene manager
    Ogre::SceneManager* OgreSceneManager() const { return sceneManager_; }

    /// Returns the parent scene
{'fraction_non_alphanumeric': 0.08472987226063518, 'fraction_numerical': 0.000703152466893238, 'mean_word_length': 3.532129580456718, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4656380', 'n_tokens_mistral': 2278, 'n_tokens_neox': 2209, 'n_words': 974}