Btw, you can also script your own tool to find out only the Min/Max ranges of specific channels.
I just tested and the pure loop over 1 million particles in a PRT stream takes about 10 seconds.
However, reading the same 1 million particles into the Stats panel of the PDV takes 237 seconds, because there are a lot of additional logical tests and array collections within a nested loop going through all channels.
But if you know the specific channels you need to explore, you could remove a lot of this general purpose logic and hard-code something that would be significantly faster.
For example, the following function will find the Min. and Max. X, Y and Z Positions of 1 million points of the currently selected PRT object in 15 seconds:
(
local st = timestamp()
local currentStream = FranticParticles.GetPRTObjectIStream $ false false
local theChannelToScan = "Position"
local theChannels = currentStream.getChannels()
local theIndex = 0
for c = 1 to theChannels.count where matchPattern theChannels[c] pattern:(theChannelToScan+" *") do theIndex = c
if theIndex > 0 do
(
local theMinValue = [10e10,10e10,10e10]
local theMaxValue = [-10e10,-10e10,-10e10]
local theData = #()
for i = 1 to 1000000 while theData != undefined do
(
theData = currentStream.readParticle()
if theData[theIndex].x > theMaxValue.x then theMaxValue.x = theData[theIndex].x
else if theData[theIndex].x < theMinValue.x do theMinValue.x = theData[theIndex].x
if theData[theIndex].y > theMaxValue.y then theMaxValue.y = theData[theIndex].y
else if theData[theIndex].y < theMinValue.y do theMinValue.y = theData[theIndex].y
if theData[theIndex].z > theMaxValue.z then theMaxValue.z = theData[theIndex].z
else if theData[theIndex].z < theMinValue.z do theMinValue.z = theData[theIndex].z
)
currentStream.close()
format "Min. % = %\n" theChannelToScan theMinValue
format "Max. % = %\n" theChannelToScan theMaxValue
format "% ms\n" (timestamp()-st)
)
)
However, it will not look for any other channels, and the code was not written to support any other arity but 3, so it only works for vectors. You can change “Position” to “Velocity” or “Normal” and it will give you the Min/Max values for that channel, too, again in about 15 seconds.
Note that it does not return the specific Min or Max value, but the Min and Max components of the channel. So in the case of Normal the Min. might look like [-1,-1,-1], but there is no such Normal, it just means that the min. X value of all possible Normals was -1, and the same was the case for Y and Z…
So this case is about 15 times faster than the Stats of PDV, but in my case it collected 8x less data (only one channel out of 8 in a PRT Volume), and it did not collect the min/max length of the vector or the average values of the various components. So it simply does less work. But if you just want to know what the minimum and maximum extent of some value is, it might help you get there faster…
I will log a wish against a C++ function in FranticParticles that could do this faster and return the min/max/average of all channels found in a stream without running MAXScript loops. It would be nice to have access to that inside of Magma, too…