diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 6cbebad..a4bc803 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -961,16 +961,36 @@ function BeamLib.ConvertBitIndexToRotationIndex( sBitIndexCombination) return nRotationIndex end +------------------------------------------------------------------------------------------------------------- +-- inverte la porzione tra nStartIndex e nEndIndex della tabella passata +local function ReverseTablePortionInPlace( Table, nStartIndex, nEndIndex) + while nStartIndex < nEndIndex do + Table[nStartIndex], Table[nEndIndex] = Table[nEndIndex], Table[nStartIndex] + nStartIndex = nStartIndex + 1 + nEndIndex = nEndIndex - 1 + end + + return Table +end + + ------------------------------------------------------------------------------------------------------------- -- reindicizza una tabella passata ripartendo dall'indice nStartIndex e mantenendo l'ordine -function BeamLib.RotateTableFromIndex( Table, nStartIndex) - local RotatedTable = {} +function BeamLib.RotateTableFromIndexInPlace( Table, nStartIndex) + local dLen = #Table - for i = 1, #Table do - RotatedTable[#RotatedTable + 1] = Table[((RotatedTable + i - 2) % #Table) + 1] - end + -- Nessuna rotazione necessaria se la tabella è vuota, ha 1 solo elemento, o la rotazione è dall'indice 1 + if dLen <= 1 or nStartIndex <= 1 or nStartIndex > dLen then + return Table + end - return RotatedTable + local k = nStartIndex - 1 + + ReverseTablePortionInPlace( Table, 1, k) -- 1. Inverte la parte inziale + ReverseTablePortionInPlace( Table, k + 1, dLen) -- 2. Inverte la parte finale + ReverseTablePortionInPlace( Table, 1, dLen) -- 3. Inverte tutto + + return Table end ------------------------------------------------------------------------------------------------------------- diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index bd80fb5..2afb658 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -845,7 +845,7 @@ local function CalculateDiceMachinings( vCuts, Parameters) local bReduceDiceDepth = Parameters.bReduceDiceDepth -- trimesh con RestLength - local idCheckCollisionTm = Part.idBoxTm + local idCheckCollisionTm = EgtCopyGlob( Part.idBoxTm, Part.idTempGroup) -- se testa o coda attaccate, si considerano nella superficie di collisione if bCannotSplitRestLength then local b3CheckCollision = BeamLib.GetPartBoxWithHeadTail( Part, sRestLengthSideForPreSimulation)