[Closed] How to make it faster?
I played around with this about a year ago but adding the RayFire_Asperity() to give may inside cuts detail. Code is not the best was just playing around. I would like to port somthing like this to the sdk but not use any third party plugins.
I see in mnmesh there is a mm->slice has some good options.
Dennis your code looks like a great starting point. Thanks for that!
here is the old crap code. It does work well but is slow and just a first write.
Fn FN_GlowFrag Frag_Objs Break_Type Inside_D Second_Facture Bake_It Detail_Amount FRAG_SIZE MAT_ID = (
if Frag_Objs.count > 0 do(
progressStart "Make Me Some GlowFrags!!!" ------------------------
actionMan.executeAction 0 "40087" -- Edit: Hold
Size_Array = #()
Size_Short = #()
Large_Frags = #()
Largest_Size = 0
Smallest_Size = 9999999999
max modify mode
Rig_Mod = MassFX_RBody()
Rig_Mod.type = 2
Rig_Mod.manualSetup = on
Rig_Mod.switchType = on
Rig_Mod.switchTypeAtFrame = random 5 20
Rig_Mod.materialID = -1565614346
Rig_Mod.density = 8
Rig_Mod.Mass = 3
Rig_Mod.staticFriction = 0.5
Rig_Mod.dynamicFriction = 0.2
Rig_Mod.bounciness = 0.1
Frag1_Mod = RayFire_Voronoi()
Frag1_Mod.pc_type = 0
Frag1_Mod.pc_numpoints = FRAG_SIZE
Frag1_Mod.seed = (Random 0 9999)
Frag1_Mod.Fragment = on
Frag1_Mod.matID = MAT_ID
if Break_Type == 1 then(
Frag1_Mod.prescale_z = (Random 5 20)
)
else(
Frag1_Mod.prescale_z = (Random 93 95)
Second_Facture = true
)
subobjectLevel = 0
Frag2_Mod = RayFire_Voronoi ()
Frag2_Mod.pc_type = 1
Frag2_Mod.Fragment = on
if Break_Type == 1 then(
Frag2_Mod.prescale_z = (Random 5 20)
Frag2_Mod.pc_numpoints = (FRAG_SIZE / 4)
)
else(
Frag2_Mod.prescale_z = 97
Frag2_Mod.pc_numpoints = 100
)
Frag2_Mod.seed = (Random 0 9999)
Frag2_Mod.matID = MAT_ID
subobjectLevel = 0
Detail_Mod = RayFire_Asperity()
Detail_Mod.triSizeMode = 1
Detail_Mod.edgeLengthAbs = Detail_Amount
Detail_Mod.selectionNoiseEnabled = on
Detail_Mod.noiseAmountLock = off
Detail_Mod.noiseAmountX = (Random 0.9 2)
Detail_Mod.noiseAmountY = (Random 0.9 2)
Detail_Mod.noiseAmountZ = (Random 0.9 2)
progressUpdate 20
for i = 1 to Frag_Objs.count do(
addModifier Frag_Objs[i] Frag1_Mod
Frags = RFMxs.explodeToElements Frag_Objs[i] deleteOriginal:true suffix:("GlowFrag_")
for f = 1 to Frags.count do(
Frags[f].wirecolor = (color (random 0 255) (random 0 255) (random 0 255))
size_O = distance Frags[f].max Frags[f].min
append Size_Array size_O
)
progressUpdate 40
if Inside_D == True do(
addModifier Frags Detail_Mod
---------progressUpdate 80
Select Frags
macros.run "Modifier Stack" "Convert_to_Mesh"
)
Sort Size_Array
Start_Num = Size_Array.count / 2
Start_Num = floor Start_Num as integer
Start_Num = Size_Array.count - Start_Num
for AC = Start_Num to Size_Array.count do(
append Size_Short Size_Array[AC]
)
for fs = 1 to Frags.count do(
size_O = distance Frags[fs].max Frags[fs].min
for ffs = 1 to Size_Short.count do(
if size_O == Size_Short[ffs] do(
append Large_Frags Frags[fs]
)
)
)
progressUpdate 40
)
if Second_Facture == True do(
for LF = 1 to Large_Frags.count do(
T_Frags = #()
New_Size = random 2 4
Frag2_Mod.pc_type = random 0 2
Frag2_Mod.pc_numpoints = (FRAG_SIZE / New_Size)
Frag2_Mod.seed = (Random 0 9999)
addModifier Large_Frags[LF] Frag2_Mod
T_Frags = RFMxs.explodeToElements Large_Frags[LF] deleteOriginal:true suffix:("GlowFrag_")
for f = 1 to T_Frags.count do(
T_Frags[f].wirecolor = (color (random 0 255) (random 0 255) (random 0 255))
)
)
progressUpdate 50
)
All_Frags = $GlowFrag* as array
if Bake_It == True do(
for BB = 1 to All_Frags.count do(
select All_Frags[BB]
Rig_Mod.meshCustomMesh = All_Frags[BB]
Rig_Mod.meshType = 6
addModifier All_Frags[BB] Rig_Mod
)
)
clearSelection()
free Large_Frags
free Size_Array
free Size_Short
completedraw()
progressUpdate 99
progressEnd()
gc()
)
)
on the subject of slicing, what method do we think the Slice modifier uses on editable mesh in operate on polygon mode ?
it’s not MeshDelta::Slice or MeshDelta::Cut (works the same only if quads). Would be the one modifier you’d like to be in the samples that’s not :banghead:. So it’s probably something proprietary And why the polygon option is not made available to the editable mesh & modifier
Havent tried it, but couldn’t it be MNMesh::Slice?
The Slice modifier changes the object class according to the used method to PolyMeshObject or Editable_mesh.
so it does, thanks pt3d, not so proprietary after all
there’s an example of how to pass a PolyObject down the pipeline in tessmod.cpp BTW