esp::assets::managers::SceneAttributesManager class

Base classes

template<class AttribsPtr>
class AttributesManager
Template Class defining responsibilities for managing attributes for different types of objects, such as scenes, primitive assets, physical objects, etc.

Constructors, destructors, conversion operators

SceneAttributesManager(assets::ResourceManager& resourceManager, ObjectAttributesManager::ptr objectAttributesMgr, PhysicsAttributesManager::ptr physicsAttributesManager)

Public functions

void setCurrPhysicsManagerAttributesHandle(const std::string& handle)
This will set the current physics manager attributes that is governing the world that this sceneAttributesManager's scenes will be created in. This is used so that upon creation of new sceneAttributes, PhysicsManagerAttributes defaults can be set in the sceneAttributes before any scene-specific values are set.
void setCurrCfgVals(const std::map<std::string, std::string>& filepaths, const std::string& lightSetup, bool frustrumCulling)
copy current SimulatorConfiguration-driven values, such as file paths, to make them available for scene attributes defaults.
auto createAttributesTemplate(const std::string& sceneAttributesHandle, bool registerTemplate = true) -> PhysicsSceneAttributes::ptr override
Creates an instance of a scene template described by passed string. For scene templates, this a file name.
auto createDefaultAttributesTemplate(const std::string& templateName, bool registerTemplate = false) -> PhysicsSceneAttributes::ptr override
Creates a an instance of scene attributes template populated with default values. Assigns the templateName as the template's handle, and render and collision handles.
auto createPrimBasedAttributesTemplate(const std::string& primAttrTemplateHandle, bool registerTemplate = true) -> PhysicsSceneAttributes::ptr
Creates an instance of a scene template described by passed string, which should be a reference to an existing primitive asset template to be used in the construction of the scene (as render and collision mesh). It returns existing instance if there is one, and nullptr if fails.

Protected functions

void setDefaultFileNameBasedAttributes(PhysicsSceneAttributes::ptr attributes, bool setFrame, const std::string& meshHandle, std::function<void(int)> meshTypeSetter) override
Perform file-name-based attributes initialization. This is to take the place of the AssetInfo::fromPath functionality, and is only intended to provide default values and other help if certain mistakes are made by the user, such as specifying an asset handle in json but not specifying the asset type corresponding to that handle. These settings should not restrict anything, only provide defaults.
auto initNewAttribsInternal(PhysicsSceneAttributes::ptr newAttributes) -> PhysicsSceneAttributes::ptr override
Used Internally. Configure newly-created attributes with any default values, before any specific values are set.
void updateTemplateHandleLists(CORRADE_UNUSED int templateID, CORRADE_UNUSED const std::string& templateHandle) override
This method will perform any necessary updating that is attributesManager-specific upon template removal, such as removing a specific template handle from the list of file-based template handles in ObjectAttributesManager. This should only be called internally.
auto createBackCompatAttributesTemplate(const std::string& sceneFilename, bool registerTemplate = true) -> PhysicsSceneAttributes::ptr
Scene is file-based lacking a descriptive .json, described by sceneFilename; populate a returned scene attributes with appropriate data. This method's intended use is to support backwards compatibility for when scene meshes are loaded without JSON files.
auto createFileBasedAttributesTemplate(const std::string& sceneFilename, bool registerTemplate = true) -> PhysicsSceneAttributes::ptr
Read and parse the json file sceneFilename and populate a returned scene attributes with appropriate data.
auto registerAttributesTemplateFinalize(PhysicsSceneAttributes::ptr sceneAttributesTemplate, const std::string& sceneAttributesHandle) -> int override
Add a std::shared_ptr<attributesType> object to the templateLibrary_. Verify that render and collision handles have been set properly. We are doing this since these values can be modified by the user.
void resetFinalize() override
Any scene-attributes-specific resetting that needs to happen on reset.
void buildCtorFuncPtrMaps() override
This function will assign the appropriately configured function pointer for the copy constructor as required by AttributesManager<PhysicsSceneAttributes::ptr>

Protected variables

ObjectAttributesManager::ptr objectAttributesMgr_
Reference to ObjectAttributesManager to give access to setting object template library using paths specified in SceneAttributes json.
PhysicsAttributesManager::ptr physicsAttributesManager_
Reference to PhysicsAttributesManager to give access to default physics manager attributes settings when sceneAttributes are created.
std::map<std::string, std::string> cfgFilepaths_
Current file paths based on SimulatorConfiguration settings. Paths can be overridden by json-specified values.
std::string cfgLightSetup_
Current lighting default value based on current SimulatorConfiguration settings. Potentially overridden by scene-specific json.
bool cfgFrustrumCulling_
Current frustrum culling setting based on current SimulatorConfiguration settings. Potentially overridden by scene-specific json.
std::string physicsManagerAttributesHandle_
Name of currently used physicsManagerAttributes.

Function documentation

void esp::assets::managers::SceneAttributesManager::setCurrPhysicsManagerAttributesHandle(const std::string& handle)

This will set the current physics manager attributes that is governing the world that this sceneAttributesManager's scenes will be created in. This is used so that upon creation of new sceneAttributes, PhysicsManagerAttributes defaults can be set in the sceneAttributes before any scene-specific values are set.

Parameters
handle The string handle referencing the physicsManagerAttributes governing the current physicsManager.

void esp::assets::managers::SceneAttributesManager::setCurrCfgVals(const std::map<std::string, std::string>& filepaths, const std::string& lightSetup, bool frustrumCulling)

copy current SimulatorConfiguration-driven values, such as file paths, to make them available for scene attributes defaults.

Parameters
filepaths the map of file paths from the configuration object
lightSetup the config-specified light setup
frustrumCulling whether or not (semantic) scene should be partitioned for culling.

PhysicsSceneAttributes::ptr esp::assets::managers::SceneAttributesManager::createAttributesTemplate(const std::string& sceneAttributesHandle, bool registerTemplate = true) override

Creates an instance of a scene template described by passed string. For scene templates, this a file name.

Parameters
sceneAttributesHandle the origin of the desired template to be created, in this case, a file name.
registerTemplate whether to add this template to the library. If the user is going to edit this template, this should be false - any subsequent editing will require re-registration. Defaults to true. If specified as true, then this function returns a copy of the registered template.
Returns a reference to the desired template.

If a template exists with this handle, this existing template will be overwritten with the newly created one if registerTemplate is true.

PhysicsSceneAttributes::ptr esp::assets::managers::SceneAttributesManager::createDefaultAttributesTemplate(const std::string& templateName, bool registerTemplate = false) override

Creates a an instance of scene attributes template populated with default values. Assigns the templateName as the template's handle, and render and collision handles.

Parameters
templateName Name to use for the attributes handle.
registerTemplate whether to add this template to the library. If the user is going to edit this template, this should be false - any subsequent editing will require re-registration. Defaults to false. If specified as true, then this function returns a copy of the registered template.
Returns a reference to the desired template, or nullptr if fails.

If a template exists with this handle, the existing template will be overwritten with the newly created one if registerTemplate is true. This method is specifically intended to directly construct an attributes template for editing, and so defaults to false for registerTemplate

PhysicsSceneAttributes::ptr esp::assets::managers::SceneAttributesManager::createPrimBasedAttributesTemplate(const std::string& primAttrTemplateHandle, bool registerTemplate = true)

Creates an instance of a scene template described by passed string, which should be a reference to an existing primitive asset template to be used in the construction of the scene (as render and collision mesh). It returns existing instance if there is one, and nullptr if fails.

Parameters
primAttrTemplateHandle The handle to an existing primitive asset template. Fails if does not.
registerTemplate whether to add this template to the library. If the user is going to edit this template, this should be false - any subsequent editing will require re-registration. Defaults to true.
Returns a reference to the desired scene template, or nullptr if fails.

void esp::assets::managers::SceneAttributesManager::setDefaultFileNameBasedAttributes(PhysicsSceneAttributes::ptr attributes, bool setFrame, const std::string& meshHandle, std::function<void(int)> meshTypeSetter) override protected

Perform file-name-based attributes initialization. This is to take the place of the AssetInfo::fromPath functionality, and is only intended to provide default values and other help if certain mistakes are made by the user, such as specifying an asset handle in json but not specifying the asset type corresponding to that handle. These settings should not restrict anything, only provide defaults.

Parameters
attributes The AbstractPhysicsAttributes object to be configured
setFrame whether the frame should be set or not (only for render assets in scenes)
meshHandle
meshTypeSetter Setter for mesh type.

PhysicsSceneAttributes::ptr esp::assets::managers::SceneAttributesManager::initNewAttribsInternal(PhysicsSceneAttributes::ptr newAttributes) override protected

Used Internally. Configure newly-created attributes with any default values, before any specific values are set.

Parameters
newAttributes Newly created attributes.

void esp::assets::managers::SceneAttributesManager::updateTemplateHandleLists(CORRADE_UNUSED int templateID, CORRADE_UNUSED const std::string& templateHandle) override protected

This method will perform any necessary updating that is attributesManager-specific upon template removal, such as removing a specific template handle from the list of file-based template handles in ObjectAttributesManager. This should only be called internally.

Parameters
templateID the ID of the template to remove
templateHandle the string key of the attributes desired.

PhysicsSceneAttributes::ptr esp::assets::managers::SceneAttributesManager::createBackCompatAttributesTemplate(const std::string& sceneFilename, bool registerTemplate = true) protected

Scene is file-based lacking a descriptive .json, described by sceneFilename; populate a returned scene attributes with appropriate data. This method's intended use is to support backwards compatibility for when scene meshes are loaded without JSON files.

Parameters
sceneFilename The mesh file name
registerTemplate whether to add this template to the library or not.
Returns a reference to the desired scene template, or nullptr if fails.

PhysicsSceneAttributes::ptr esp::assets::managers::SceneAttributesManager::createFileBasedAttributesTemplate(const std::string& sceneFilename, bool registerTemplate = true) protected

Read and parse the json file sceneFilename and populate a returned scene attributes with appropriate data.

Parameters
sceneFilename The configuration file to parse.
registerTemplate whether to add this template to the library or not.
Returns a reference to the desired scene template, or nullptr if fails.

int esp::assets::managers::SceneAttributesManager::registerAttributesTemplateFinalize(PhysicsSceneAttributes::ptr sceneAttributesTemplate, const std::string& sceneAttributesHandle) override protected

Add a std::shared_ptr<attributesType> object to the templateLibrary_. Verify that render and collision handles have been set properly. We are doing this since these values can be modified by the user.

Parameters
sceneAttributesTemplate The attributes template.
sceneAttributesHandle The key for referencing the template in the templateLibrary_.
Returns The index in the templateLibrary_ of object template.