@@ -851,8 +851,8 @@ int32_t FractureToolImpl::slicing(uint32_t chunkId, const SlicingConfiguration&
851
851
ch.isChanged = true ;
852
852
ch.flags = ChunkInfo::NO_FLAGS;
853
853
ch.parentChunkId = replaceChunk ? mChunkData [chunkInfoIndex].parentChunkId : chunkId;
854
- std::vector<ChunkInfo > xSlicedChunks;
855
- std::vector<ChunkInfo > ySlicedChunks;
854
+ std::vector<Mesh* > xSlicedChunks;
855
+ std::vector<Mesh* > ySlicedChunks;
856
856
std::vector<uint32_t > newlyCreatedChunksIds;
857
857
/* *
858
858
Slice along x direction
@@ -865,12 +865,12 @@ int32_t FractureToolImpl::slicing(uint32_t chunkId, const SlicingConfiguration&
865
865
866
866
setCuttingBox (center, -lDir, slBox, 20 , mPlaneIndexerOffset );
867
867
bTool.performFastCutting (mesh, slBox, BooleanConfigurations::BOOLEAN_INTERSECTION ());
868
- setChunkInfoMesh (ch, bTool.createNewMesh ());
869
-
870
- if (ch.getMesh () != 0 )
868
+ Mesh* xSlice = bTool.createNewMesh ();
869
+ if (xSlice != nullptr )
871
870
{
872
- xSlicedChunks.push_back (ch );
871
+ xSlicedChunks.push_back (xSlice );
873
872
}
873
+
874
874
inverseNormalAndIndices (slBox);
875
875
++mPlaneIndexerOffset ;
876
876
bTool.performFastCutting (mesh, slBox, BooleanConfigurations::BOOLEAN_DIFFERENCE ());
@@ -883,34 +883,32 @@ int32_t FractureToolImpl::slicing(uint32_t chunkId, const SlicingConfiguration&
883
883
}
884
884
center.x += x_offset + (rnd->getRandomValue ()) * conf.offset_variations * x_offset;
885
885
}
886
- if (mesh != 0 )
886
+ if (mesh != nullptr )
887
887
{
888
- setChunkInfoMesh (ch, mesh);
889
- xSlicedChunks.push_back (ch);
888
+ xSlicedChunks.push_back (mesh);
890
889
}
891
890
892
-
893
891
for (uint32_t chunk = 0 ; chunk < xSlicedChunks.size (); ++chunk)
894
892
{
895
893
center = NvVec3 (0 , sourceBBox.minimum .y , 0 );
896
894
center.y += y_offset;
897
895
dir = NvVec3 (0 , 1 , 0 );
898
- mesh = xSlicedChunks[chunk]. getMesh () ;
896
+ mesh = xSlicedChunks[chunk];
899
897
900
898
for (int32_t slice = 0 ; slice < y_slices; ++slice)
901
899
{
902
900
NvVec3 randVect =
903
901
NvVec3 (2 * rnd->getRandomValue () - 1 , 2 * rnd->getRandomValue () - 1 , 2 * rnd->getRandomValue () - 1 );
904
902
NvVec3 lDir = dir + randVect * conf.angle_variations ;
905
903
906
-
907
904
setCuttingBox (center, -lDir, slBox, 20 , mPlaneIndexerOffset );
908
905
bTool.performFastCutting (mesh, slBox, BooleanConfigurations::BOOLEAN_INTERSECTION ());
909
- setChunkInfoMesh (ch, bTool.createNewMesh () );
910
- if (ch. getMesh () != 0 )
906
+ Mesh* ySlice = bTool.createNewMesh ();
907
+ if (ySlice != nullptr )
911
908
{
912
- ySlicedChunks.push_back (ch );
909
+ ySlicedChunks.push_back (ySlice );
913
910
}
911
+
914
912
inverseNormalAndIndices (slBox);
915
913
++mPlaneIndexerOffset ;
916
914
bTool.performFastCutting (mesh, slBox, BooleanConfigurations::BOOLEAN_DIFFERENCE ());
@@ -923,35 +921,36 @@ int32_t FractureToolImpl::slicing(uint32_t chunkId, const SlicingConfiguration&
923
921
}
924
922
center.y += y_offset + (rnd->getRandomValue ()) * conf.offset_variations * y_offset;
925
923
}
926
- if (mesh != 0 )
924
+ if (mesh != nullptr )
927
925
{
928
- setChunkInfoMesh (ch, mesh);
929
- ySlicedChunks.push_back (ch);
926
+ ySlicedChunks.push_back (mesh);
930
927
}
931
928
}
932
929
933
-
934
930
for (uint32_t chunk = 0 ; chunk < ySlicedChunks.size (); ++chunk)
935
931
{
936
932
center = NvVec3 (0 , 0 , sourceBBox.minimum .z );
937
933
center.z += z_offset;
938
934
dir = NvVec3 (0 , 0 , 1 );
939
- mesh = ySlicedChunks[chunk]. getMesh () ;
935
+ mesh = ySlicedChunks[chunk];
940
936
941
937
for (int32_t slice = 0 ; slice < z_slices; ++slice)
942
938
{
943
939
NvVec3 randVect =
944
940
NvVec3 (2 * rnd->getRandomValue () - 1 , 2 * rnd->getRandomValue () - 1 , 2 * rnd->getRandomValue () - 1 );
945
941
NvVec3 lDir = dir + randVect * conf.angle_variations ;
942
+
946
943
setCuttingBox (center, -lDir, slBox, 20 , mPlaneIndexerOffset );
947
944
bTool.performFastCutting (mesh, slBox, BooleanConfigurations::BOOLEAN_INTERSECTION ());
948
- setChunkInfoMesh (ch, bTool.createNewMesh () );
949
- if (ch. getMesh () != 0 )
945
+ Mesh* ySlice = bTool.createNewMesh ();
946
+ if (ySlice != nullptr )
950
947
{
948
+ setChunkInfoMesh (ch, ySlice);
951
949
ch.chunkId = createId ();
952
950
newlyCreatedChunksIds.push_back (ch.chunkId );
953
951
mChunkData .push_back (ch);
954
952
}
953
+
955
954
inverseNormalAndIndices (slBox);
956
955
++mPlaneIndexerOffset ;
957
956
bTool.performFastCutting (mesh, slBox, BooleanConfigurations::BOOLEAN_DIFFERENCE ());
@@ -964,16 +963,15 @@ int32_t FractureToolImpl::slicing(uint32_t chunkId, const SlicingConfiguration&
964
963
}
965
964
center.z += z_offset + (rnd->getRandomValue ()) * conf.offset_variations * z_offset;
966
965
}
967
- if (mesh != 0 )
966
+ if (mesh != nullptr )
968
967
{
969
- ch.chunkId = createId ();
970
968
setChunkInfoMesh (ch, mesh);
971
- mChunkData . push_back (ch );
969
+ ch. chunkId = createId ( );
972
970
newlyCreatedChunksIds.push_back (ch.chunkId );
971
+ mChunkData .push_back (ch);
973
972
}
974
973
}
975
974
976
-
977
975
delete slBox;
978
976
979
977
mChunkData [chunkInfoIndex].isLeaf = false ;
@@ -1047,8 +1045,8 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat
1047
1045
ch.isChanged = true ;
1048
1046
ch.flags = ChunkInfo::NO_FLAGS;
1049
1047
ch.parentChunkId = replaceChunk ? mChunkData [chunkInfoIndex].parentChunkId : chunkId;
1050
- std::vector<ChunkInfo > xSlicedChunks;
1051
- std::vector<ChunkInfo > ySlicedChunks;
1048
+ std::vector<Mesh* > xSlicedChunks;
1049
+ std::vector<Mesh* > ySlicedChunks;
1052
1050
std::vector<uint32_t > newlyCreatedChunksIds;
1053
1051
float noisyPartSize = 1 .2f ;
1054
1052
// int32_t acceleratorRes = 8;
@@ -1068,11 +1066,12 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat
1068
1066
SweepingAccelerator accel (mesh);
1069
1067
SweepingAccelerator dummy (slBox);
1070
1068
bTool.performBoolean (mesh, slBox, &accel, &dummy, BooleanConfigurations::BOOLEAN_DIFFERENCE ());
1071
- setChunkInfoMesh (ch, bTool.createNewMesh () );
1072
- if (ch. getMesh () != 0 )
1069
+ Mesh* xSlice = bTool.createNewMesh ();
1070
+ if (xSlice != nullptr )
1073
1071
{
1074
- xSlicedChunks.push_back (ch );
1072
+ xSlicedChunks.push_back (xSlice );
1075
1073
}
1074
+
1076
1075
inverseNormalAndIndices (slBox);
1077
1076
++mPlaneIndexerOffset ;
1078
1077
bTool.performBoolean (mesh, slBox, &accel, &dummy, BooleanConfigurations::BOOLEAN_INTERSECTION ());
@@ -1086,19 +1085,19 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat
1086
1085
}
1087
1086
center.x += x_offset + (rnd->getRandomValue ()) * conf.offset_variations * x_offset;
1088
1087
}
1089
- if (mesh != 0 )
1088
+ if (mesh != nullptr )
1090
1089
{
1091
- setChunkInfoMesh (ch, mesh);
1092
- xSlicedChunks.push_back (ch);
1090
+ xSlicedChunks.push_back (mesh);
1093
1091
}
1092
+
1094
1093
slBox = getCuttingBox (center, dir, 20 , 0 , mInteriorMaterialId );
1095
1094
uint32_t slicedChunkSize = xSlicedChunks.size ();
1096
1095
for (uint32_t chunk = 0 ; chunk < slicedChunkSize; ++chunk)
1097
1096
{
1098
1097
center = NvVec3 (0 , sourceBBox.minimum .y , 0 );
1099
1098
center.y += y_offset;
1100
1099
dir = NvVec3 (0 , 1 , 0 );
1101
- mesh = xSlicedChunks[chunk]. getMesh () ;
1100
+ mesh = xSlicedChunks[chunk];
1102
1101
1103
1102
for (int32_t slice = 0 ; slice < y_slices; ++slice)
1104
1103
{
@@ -1114,11 +1113,12 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat
1114
1113
SweepingAccelerator accel (mesh);
1115
1114
SweepingAccelerator dummy (slBox);
1116
1115
bTool.performBoolean (mesh, slBox, &accel, &dummy, BooleanConfigurations::BOOLEAN_DIFFERENCE ());
1117
- setChunkInfoMesh (ch, bTool.createNewMesh () );
1118
- if (ch. getMesh () != 0 )
1116
+ Mesh* ySlice = bTool.createNewMesh ();
1117
+ if (ySlice != nullptr )
1119
1118
{
1120
- ySlicedChunks.push_back (ch );
1119
+ ySlicedChunks.push_back (ySlice );
1121
1120
}
1121
+
1122
1122
inverseNormalAndIndices (slBox);
1123
1123
++mPlaneIndexerOffset ;
1124
1124
bTool.performBoolean (mesh, slBox, &accel, &dummy, BooleanConfigurations::BOOLEAN_INTERSECTION ());
@@ -1132,10 +1132,9 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat
1132
1132
}
1133
1133
center.y += y_offset + (rnd->getRandomValue ()) * conf.offset_variations * y_offset;
1134
1134
}
1135
- if (mesh != 0 )
1135
+ if (mesh != nullptr )
1136
1136
{
1137
- setChunkInfoMesh (ch, mesh);
1138
- ySlicedChunks.push_back (ch);
1137
+ ySlicedChunks.push_back (mesh);
1139
1138
}
1140
1139
}
1141
1140
@@ -1144,7 +1143,7 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat
1144
1143
center = NvVec3 (0 , 0 , sourceBBox.minimum .z );
1145
1144
center.z += z_offset;
1146
1145
dir = NvVec3 (0 , 0 , 1 );
1147
- mesh = ySlicedChunks[chunk]. getMesh () ;
1146
+ mesh = ySlicedChunks[chunk];
1148
1147
1149
1148
for (int32_t slice = 0 ; slice < z_slices; ++slice)
1150
1149
{
@@ -1159,13 +1158,15 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat
1159
1158
SweepingAccelerator accel (mesh);
1160
1159
SweepingAccelerator dummy (slBox);
1161
1160
bTool.performBoolean (mesh, slBox, &accel, &dummy, BooleanConfigurations::BOOLEAN_DIFFERENCE ());
1162
- setChunkInfoMesh (ch, bTool.createNewMesh () );
1163
- if (ch. getMesh () != 0 )
1161
+ Mesh* ySlice = bTool.createNewMesh ();
1162
+ if (ySlice != nullptr )
1164
1163
{
1164
+ setChunkInfoMesh (ch, ySlice);
1165
1165
ch.chunkId = createId ();
1166
1166
mChunkData .push_back (ch);
1167
1167
newlyCreatedChunksIds.push_back (ch.chunkId );
1168
1168
}
1169
+
1169
1170
inverseNormalAndIndices (slBox);
1170
1171
++mPlaneIndexerOffset ;
1171
1172
bTool.performBoolean (mesh, slBox, &accel, &dummy, BooleanConfigurations::BOOLEAN_INTERSECTION ());
@@ -1179,12 +1180,12 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat
1179
1180
}
1180
1181
center.z += z_offset + (rnd->getRandomValue ()) * conf.offset_variations * z_offset;
1181
1182
}
1182
- if (mesh != 0 )
1183
+ if (mesh != nullptr )
1183
1184
{
1184
- ch.chunkId = createId ();
1185
1185
setChunkInfoMesh (ch, mesh);
1186
- mChunkData . push_back (ch );
1186
+ ch. chunkId = createId ( );
1187
1187
newlyCreatedChunksIds.push_back (ch.chunkId );
1188
+ mChunkData .push_back (ch);
1188
1189
}
1189
1190
}
1190
1191
@@ -1206,6 +1207,7 @@ int32_t FractureToolImpl::slicingNoisy(uint32_t chunkId, const SlicingConfigurat
1206
1207
1207
1208
return 0 ;
1208
1209
}
1210
+
1209
1211
int32_t FractureToolImpl::cut (uint32_t chunkId, const NvcVec3& normal , const NvcVec3& point,
1210
1212
const NoiseConfiguration& noise, bool replaceChunk, RandomGeneratorBase* rnd)
1211
1213
{
0 commit comments