DrawLine's clipping performance test

Started by Monsieur OUXX, Thu 03/12/2015 18:05:06

Previous topic - Next topic

Monsieur OUXX

#20
Quote from: Gurok on Mon 07/12/2015 23:50:39
I'd like to add to Monsieur OUXX's analysis that it should actually be possible to homogenise the output of the two algorithms. For us to maintain compatibility though, we'd have to look at rewriting FastLine.

Quote from: Snarkyquote author=Snarky link=topic=52978.msg636526561#msg636526561 date=1449502637]
I'm pretty sure you could without too much difficulty, but it's just not really worth it.

Both comments are true, but only if you have perfect understanding of how Allegro's drawing routine works internally. Because line-drawing algorithms are more subtle than one would think (for example: how to balance the step's extra pixels at the start and at the end of the line, that sort of decisions).

Therefore, this is dangerous business. Allegro could do this (I'm 99% certain that this is how they managed to suppress the second routine in Allegro 5: they simply merged the two algorithms) but... only because they know their own algorithm.

The real question is: if people think that the inaccuracy is insignificant, then yes, OK, let's use only one function that will switch to one algorithm or the other depending on the situation. I can't decide if this would be a source of problems for the end-scripter -- who could get confused trying to understand why his animated lines are sometimes slightly off. One thing is sure: it would be visible only in very low res.
You can have an idea of how visible it is by running this simulation (use the compiled file in "Compiled" unless you have the modified 3.3.5 posted by CW)

I'm against a general game option suggested by Gilbert.

 

Gilbert

IF it is possible that the engine can decide which algorithm to use itself then it's fine, and neither as a game option nor an extra function parameter would be necessary.

If this is not the case, however, remember the main reason(at least for now) for confusingly bringing up two different algorithms here is performance, and that's rarely a concern when DrawLine() is not used extensively. It's only when many long(and off-screen/off-surface) lines being drawn at once will this become an issue, so being able to switch the algorithm used at once for subsequent function calls would be more useful than having to tell the function to use the alternate algorithm(by means of the additional optional parameter) every single time it is needed.

Monsieur OUXX

Final suggestion :
- OK for a global game option like this, I've changed my mind:
Code: ags

SetGameOption(OPT_DRAWLINEMODE, 1); //0 for 'Let AGS choose' (default), 1 for 'always traditional drawline'

- OK for always using the FastLine algorithm where possible. The inaccuracy is really insignificant (see my simulation in my previous post)

@CW: it's up to you now.
 

Crimson Wizard

What is "let AGS choose", what is the algorithm of choosing?

Monsieur OUXX

Quote from: Crimson Wizard on Thu 10/12/2015 13:45:15
What is "let AGS choose", what is the algorithm of choosing?
Sorry, I shouldn't have changed the words used by Gilbert. That's just plain old FastLine.
 

SMF spam blocked by CleanTalk