Well I am in the progress of making a video explaining the current progress of the engine and I am hoping to get that out this week sometime before the new year.
In the mean time however I have decided to make a smallish post somewhat directed at Raxx here (hint hint);p
So while I was on holiday time I took another look at random point generation on pollygons (once again specifically a 3D triangle) this time being successful. At first I was trying to generate a value for one side of the triangle and get a horizontal line for this by getting the same distance from vertex A at the adjacent line and then generating a random value between those points. I realized this was wrong for it favoured vertex A and gave a higher probability to generate more points near it (because vertex A had less space near it between the two edges it was connected to).
I also named the two lines I was generating values for U and V which is wrong in the Barycentric sense (since Barycentric coordinates is all about balanced raitos of mass). At this point (and after many different rough sketches) I decided to take another look at the barycentric system and found the formula for the barycentric collision detection. I took a look at it and decided to do it in reverse (instead of trying to find U and V in the formula I substituted for U and V with a random value).
This is the formula (Where A B C is the vertices of the triangle, and U and V is the coordinates)
A + U * (C - A) + V * (B - A)
So I substituted for U and V with a random value between 0 and 1 (as a floating point). But doing so results in a square of random points. This is because when the sum of U and V are greater than one, the point the formula makes will be outside of the triangle (if the numbers are below zero they will be as well but in the opposite direction). Once again I set out to solve this and it took me a while, with some attempts favouring A B or C (or all but the center) before I realized the simplest solution.
I simply have an if statement to check whether the sum of U and V is greater than one. If it is then I just flip the values from one by taking a value of 1 and subtracting both the UV coordinates (individually) moving the points outside of the triangle back onto it and evenly without any favouring.
In pseudo code it looks like this
U = random_value_between (0,1)
V = random_value_between (0,1)
if (U+V > 1.0)
{
U = 1 - U
V = 1 - V
}
GeneratedPoint = A + U * (C - A) + V * (B - A)
So if you want to use this for your phur scripts raxx go head its ridiculous fast.
I can generate 1,000,000 points along a single triangle in about 0.249605 seconds
and 1,000 in 0.000247805 seconds on a i7-4770k processor.
EDIT: Image uploading works again, thank-you Steve!