Class Scene

class Scene

Public Functions

explicit Scene(uint16_t sceneId, Scene **ref)
~Scene()
CLASS_NO_COPY_MOVE(Scene)
void update(float deltaTime)
void draw(float deltaTime)
inline SceneConf &getConf()
inline uint16_t getId() const
inline Camera *getCamera(uint32_t index = 0)
inline Camera &getActiveCamera()
inline Coll::CollisionScene &getCollision()
void onObjectCollision(const Coll::CollEvent &event)
inline void sendEvent(
uint16_t targetId,
uint16_t senderId,
uint16_t type,
uint32_t value
)
inline void addCamera(Camera *cam)
inline void removeCamera(Camera *cam)
template<typename T>
inline T *getRenderPipeline()

Returns current (typed) rendering pipeline.

If the expected type is not the correct one, returns nullptr. This function can be used to safely access pipeline-specific features.

Template Parameters:

T – Type of the expected rendering pipeline

Returns:

Pointer to the rendering pipeline of type T, or nullptr if the type does not match

uint16_t addObject(
uint32_t prefabIdx,
const fm_vec3_t &pos = {0, 0, 0},
const fm_vec3_t &scale = {1, 1, 1},
const fm_quat_t &rot = {0, 0, 0, 1}
)

Spawns an object from a prefab into the scene.

Note that this will not happen immediately, but at the start of the next frame. The returned value is the ID of the new object, which becomes valid when it spawns.

Parameters:
  • prefabIdx – Index of the prefab asset, use _asset suffix

  • pos – initial pos (default origin)

  • scale – initial scale (default 1)

  • rot – initial rotation (none)

Returns:

ID of the new object

void removeObject(Object &obj)
Object *getObjectById(uint16_t objId) const
inline uint32_t getObjectCount() const
template<typename F>
inline void iterObjectChildren(uint16_t parentId, F &&f) const

Iterates over all direct children of the given parent object ID.

If you need nested iteration, call this function recursively.

Note: This function is intentionally a template with a callback. Doing so generates the same ASM as a direct loops with an if+continue, whereas iterators or std::view performs worse.

Template Parameters:

F

Parameters:
  • parentId – object id of the parent

  • f – callback function, takes Object* as argument

inline Lighting &getLighting()
Lighting &startLightingOverride(bool copyExisting = true)
void endLightingOverride()

Public Members

uint64_t ticksActorUpdate = {0}
uint64_t ticksGlobalUpdate = {0}
uint64_t ticksGlobalDraw = {0}
uint64_t ticksDraw = {0}
uint32_t memObjects = {0}
bool needsObjStateUpdate = {false}