MCPcopy Create free account
hub / github.com/ddiakopoulos/polymer / reset

Method reset

libraries/lib-engine/src/scene.cpp:238–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236}
237
238void scene::reset(int2 default_renderer_resolution, bool create_default_entities)
239{
240 // Clear existing scene graph objects first
241 graph.clear();
242
243 graph.set_scene(this); // Ensure graph has scene pointer
244
245 // Create renderer with the specified resolution (requires GL context to be current)
246 renderer_settings render_settings;
247 render_settings.renderSize = default_renderer_resolution;
248 renderer.reset(new pbr_renderer(render_settings));
249
250 // Create collision system
251 the_collision_system.reset(new collision_system(graph));
252
253 // Create a material mat_library
254 mat_library.reset(new polymer::material_library());
255
256 // Resolving assets is the last thing we should do
257 resolver.reset(new polymer::asset_resolver(this, mat_library.get()));
258
259 if (create_default_entities)
260 {
261 // Create procedural skybox entity
262 {
263 base_object skybox_obj("procedural-skybox");
264 skybox_obj.add_component(transform_component());
265 skybox_obj.add_component(the_procedural_skybox);
266 instantiate(std::move(skybox_obj));
267 }
268
269 // Create IBL cubemap entity
270 {
271 base_object ibl_obj("ibl-cubemap");
272 ibl_obj.add_component(transform_component());
273 ibl_obj.add_component(the_cubemap);
274 instantiate(std::move(ibl_obj));
275 }
276
277 // Create sun directional light entity
278 {
279 base_object sun_obj("sun-light");
280 sun_obj.add_component(transform_component());
281 directional_light_component sun_light;
282 sun_light.data.direction = float3(0, -1, 0);
283 sun_light.data.color = float3(1, 1, 1);
284 sun_light.data.amount = 1.0f;
285 sun_obj.add_component(sun_light);
286 base_object & created_sun = instantiate(std::move(sun_obj));
287
288 // Link the sun to the skybox
289 for (auto & [e, obj] : graph.graph_objects)
290 {
291 if (auto * skybox = obj.get_component<procedural_skybox_component>())
292 {
293 skybox->sun_directional_light = created_sun.get_entity();
294 break;
295 }

Callers 15

disconnectMethod · 0.45
pbr_rendererMethod · 0.45
PlyFileMethod · 0.45
gs_viewer_appMethod · 0.45
on_inputMethod · 0.45
on_window_closeMethod · 0.45
asset_browser_windowMethod · 0.45
on_window_closeMethod · 0.45
on_updateMethod · 0.45
scene_editor_appMethod · 0.45
on_inputMethod · 0.45

Calls 7

transform_componentClass · 0.85
add_componentMethod · 0.80
clearMethod · 0.45
set_sceneMethod · 0.45
getMethod · 0.45
get_entityMethod · 0.45
refreshMethod · 0.45

Tested by

no test coverage detected