Scene

// 3D layer. Scene usage must be while the engine is running.
class Scene
{
public:
    // Get ray query host entity.
    RVAPI EntKey GetRQIHost() const;

    // Get ray query hit normal.
    RVAPI const S3f &GetRQINormal() const;

    // Get ray query hit position.
    RVAPI const S3f &GetRQIPos() const;

    // Get static entities.
    RVAPI Entities GetStaticEntities() const;

    // Get dynamic entities.
    RVAPI Entities GetDynamicEntities() const;

    // Get current overlay.
    template<typename K = Overlay>
    K &GetOverlay() const { return *(K *)overlay(); }

    // Get current world.
    World GetWorld() const;

    // Add camera.
    RVAPI void AddCamera(Camera &camera);

    // Remove camera.
    RVAPI void RemoveCamera(Camera &camera);

    // Add light.
    RVAPI void AddLight(Light &light);

    // Update light.
    RVAPI void UpdateLight(Light &light);

    // Remove light.
    RVAPI void RemoveLight(Light &light);

    // Add geometry.
    RVAPI void AddGeometry(Geometry &geom);

    // Update geometry.
    RVAPI void UpdateGeometry(Geometry &geom);

    // Remove geometry.
    RVAPI void RemoveGeometry(Geometry &geom);

    // Set fog. [seeing] is distance in meters fog starts. [density] is the opaqueness
    // of the fog. [curve] is softness of fog edge. Default = 1.
    RVAPI void SetFog(const Color &color, float seeing = 0, float density = 1, float curve = 1);

    // Clear fog.
    RVAPI void ClearFog();

    // Set scene light grid parameters. [dim] is the dimension of the light grid in meters.
    // [div] is number of divisions on the grid axis. [origin] is origin of the light grid,
    // default = (0,0,0). Any light outside of the light grid is an environment light.
    RVAPI void SetLightGrid(float dimX, float dimY, float dimZ, float divX, float divY,
        float divZ, float originX = 0, float originY = 0, float originZ = 0);

    // Show skybox.
    RVAPI void ShowSkybox(wcstr name);

    // Hide skybox.
    RVAPI void HideSkybox();

    // Incorporate loaded assets into scene.
    RVAPI void Finalize();

    // Run scene and return exit code when finished.
    RVAPI int Run();

    // Manual forward.
    RVAPI void Forward();

    // Set ray query screen position.
    RVAPI void SetRQIPos(const S2i &pos);

    // Set scene exit code. This is a caller defined value. -1 is reserved for app close.
    RVAPI void SetExitCode(int exitCode);

    // Enable/Disable probe.
    RVAPI void EnableProbe(bool enable = true);

    // Serialize entities to [file].
    RVAPI void Serialize(File &file) const;

    // Allocate memory for overlay. Usage: new (scene.AllocOverlay<OverlayType>()) OverlayType().
    template<typename K = Overlay>
    void *AllocOverlay() { return overlay.Alloc<K>(); }

    // Internal.
    RVAPI void *operator () () const;

    // Construct scene with static and dynamic entities settings. See Entities comments.
    RVAPI Scene(uint sBlockSize = 512, uint sIncr = 32, uint dBlockSize = 512, uint dIncr = 32);

    // Destructor.
    RVAPI virtual ~Scene();

protected:
    // Forward callback.
    RVAPI virtual void OnForward() {}

private:
    SafePtr<Overlay> overlay;

    friend class SceneBridge;
};