@@ -35,6 +35,7 @@ ComponentItemInternalData(MeshMaterialMng* mmg)
3535, m_material_mng(mmg)
3636, m_component_item_internal_storage(MemoryUtils::getAllocatorForMostlyReadOnlyData())
3737, m_shared_infos(MemoryUtils::getAllocatorForMostlyReadOnlyData())
38+ , m_mat_items_internal_range(MemoryUtils::getAllocatorForMostlyReadOnlyData())
3839{
3940 // Il y a une instance pour les MatCell, les EnvCell et les AllEnvCell
4041 // Il ne faut ensuite plus modifier ce tableau car on conserve des pointeurs
@@ -49,9 +50,8 @@ void ComponentItemInternalData::
4950endCreate ()
5051{
5152 const Int32 nb_env = m_material_mng->environments ().size ();
52- m_mat_items_internal.clear ();
5353 m_mat_items_internal.resize (nb_env);
54-
54+ m_mat_items_internal_range. resize (nb_env);
5555 _initSharedInfos ();
5656}
5757
@@ -63,20 +63,21 @@ endCreate()
6363void ComponentItemInternalData::
6464_resetItemsInternal ()
6565{
66+ ComponentItemInternalLocalId internal_local_id;
67+ ArrayView<ComponentItemInternal> storage = m_component_item_internal_storage;
68+
6669 ComponentItemSharedInfo* all_env_shared_info = allEnvSharedInfo ();
67- for (ComponentItemInternal& x : m_all_env_items_internal )
68- x. _reset (all_env_shared_info);
70+ for (ComponentItemInternalLocalId id : m_all_env_items_internal_range )
71+ storage[id. localId ()]. _reset (id, all_env_shared_info);
6972
7073 ComponentItemSharedInfo* env_shared_info = envSharedInfo ();
71- for (ComponentItemInternal& x : m_env_items_internal)
72- x._reset (env_shared_info);
73-
74- for (const MeshEnvironment* env : m_material_mng->trueEnvironments ()) {
75- ArrayView<ComponentItemInternal> mat_items_internal = matItemsInternal (env->id ());
76- ComponentItemSharedInfo* mat_shared_info = matSharedInfo ();
77- for (ComponentItemInternal& x : mat_items_internal) {
78- x._reset (mat_shared_info);
79- }
74+ for (ComponentItemInternalLocalId id : m_env_items_internal_range)
75+ storage[id.localId ()]._reset (id, env_shared_info);
76+
77+ ComponentItemSharedInfo* mat_shared_info = matSharedInfo ();
78+ for (ComponentItemInternalRange mat_range : m_mat_items_internal_range) {
79+ for (ComponentItemInternalLocalId id : mat_range)
80+ storage[id.localId ()]._reset (id, mat_shared_info);
8081 }
8182}
8283
@@ -93,6 +94,7 @@ resizeComponentItemInternals(Int32 max_local_id, Int32 total_env_cell)
9394 // dès qu'un des nombre d'élément change.
9495 Int32 total_nb_internal = 0 ;
9596 total_nb_internal += max_local_id; // Pour les AllEnvCell
97+
9698 total_nb_internal += total_env_cell; // Pour les EnvCell
9799 for (const MeshEnvironment* env : m_material_mng->trueEnvironments ())
98100 total_nb_internal += env->totalNbCellMat ();
@@ -103,16 +105,24 @@ resizeComponentItemInternals(Int32 max_local_id, Int32 total_env_cell)
103105 // Maintenant récupère les vues sur chaque partie de 'm_component_item_internal_storage'
104106 {
105107 m_all_env_items_internal = m_component_item_internal_storage.subView (0 , max_local_id);
108+ m_all_env_items_internal_range.setRange (0 , max_local_id);
106109 m_env_items_internal = m_component_item_internal_storage.subView (max_local_id, total_env_cell);
110+ m_env_items_internal_range.setRange (max_local_id, total_env_cell);
107111 Int32 index_in_container = max_local_id + total_env_cell;
108112 for (const MeshEnvironment* env : m_material_mng->trueEnvironments ()) {
109113 Int32 nb_cell_mat = env->totalNbCellMat ();
110- m_mat_items_internal[env->id ()] = m_component_item_internal_storage.subView (index_in_container, nb_cell_mat);
114+ Int32 env_id = env->id ();
115+ m_mat_items_internal[env_id] = m_component_item_internal_storage.subView (index_in_container, nb_cell_mat);
116+ m_mat_items_internal_range[env_id].setRange (index_in_container, nb_cell_mat);
111117 index_in_container += nb_cell_mat;
112118 }
113119 }
114120
115121 _resetItemsInternal ();
122+
123+ // Met à jour les vues sur m_component_item_internal_storage.
124+ for (ComponentItemSharedInfo& x : m_shared_infos)
125+ x.m_component_item_internal_view = m_component_item_internal_storage;
116126}
117127
118128/* ---------------------------------------------------------------------------*/
@@ -128,20 +138,22 @@ _initSharedInfos()
128138 // ne faut pas que conteneurs associés de \a m_materials_mng soient modifiées.
129139 // Normalement ce n'est pas le cas, car la liste des constituants est fixe.
130140 ComponentItemSharedInfo* info_mat = sharedInfo (LEVEL_MATERIAL);
141+ ComponentItemSharedInfo* info_env = sharedInfo (LEVEL_ENVIRONMENT);
142+ ComponentItemSharedInfo* info_all_env = sharedInfo (LEVEL_ALLENVIRONMENT);
143+
131144 info_mat->m_level = LEVEL_MATERIAL;
132145 info_mat->m_item_shared_info = item_shared_info;
133146 info_mat->m_components = m_material_mng->materialsAsComponents ();
147+ info_mat->m_parent_component_item_shared_info = info_env;
134148
135- ComponentItemSharedInfo* info_env = sharedInfo (LEVEL_ENVIRONMENT);
136149 info_env->m_level = LEVEL_ENVIRONMENT;
137150 info_env->m_item_shared_info = item_shared_info;
138151 info_env->m_components = m_material_mng->environmentsAsComponents ();
152+ info_env->m_parent_component_item_shared_info = info_all_env;
139153
140- ComponentItemSharedInfo* info_all_env = sharedInfo (LEVEL_ALLENVIRONMENT);
141154 info_all_env->m_level = LEVEL_ALLENVIRONMENT;
142155 info_all_env->m_item_shared_info = item_shared_info;
143156 info_all_env->m_components = ConstArrayView<IMeshComponent*>();
144-
145157 info () << " EndCreate ComponentItemInternalData nb_mat=" << info_mat->m_components .size ()
146158 << " nb_env=" << info_env->m_components .size ();
147159}
0 commit comments