-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Contrail solid delay of 4 &color fix #19089
Conversation
Turned to draft, I should still smooth from tail direction |
OK, it is cool now |
That sounds like a naming/definition issue: you need two points to define a line, so the shortest option exposed to the modder as length 1 should be when there is two points. |
And probably we should directly add 1 to all length when contrail is created after this PR? Now as you can see if renderlength == 2, the Render() will only renders 1 length, which is also buggy. |
e9847bd
to
c45e972
Compare
@pchote I suddenly worry that, will .Net executes the
by the order from left to right and don't optimize *1000 and /1000? |
Those likely shouldn't be optimized to avoid big rounding errors? |
yes. although it performs like it won't optimize it. Update: |
OK since we worry about storage and time cost so I use a simple and stupid way. |
fix comment |
@@ -73,11 +73,31 @@ public void Render(WorldRenderer wr) | |||
// Start of the first line segment is the tail of the list - don't smooth it. | |||
var curPos = trail[Index(next - skip - 1)]; | |||
var curColor = color; | |||
for (var i = 0; i < length - skip - 4; i++) | |||
|
|||
for (var i = 1; i < renderLength; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this changed from 0 to 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because renderLength
is now length - skip
, for readable I make i = 1 instead of make i < renderLength - 1
.
If we make i = 0 base on this design, the contrail will be rendered to (0,0) in map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop part was tricky and with low readability so I tested frequently to get the correct boundary.
So should I mark the conversation as solved or the reviewer? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm that this does nice contrails with length 4.
I guess I also need a rebase |
nextZ += prepos.Z; | ||
} | ||
|
||
nextPos = new WPos((int)(nextX / k), (int)(nextY / k), (int)(nextZ / k)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nextPos = new WPos((int)(nextX / k), (int)(nextY / k), (int)(nextZ / k)); | |
var nextPos = new WPos((int)(nextX / k), (int)(nextY / k), (int)(nextZ / k)); |
And then remove the var nextPos = WPos.Zero;
line above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
// Need at least 4 points to smooth the contrail over | ||
if (length - skip < 4) | ||
var renderLength = length - skip; | ||
if (renderLength <= 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume with a renderLength
of 1 we will never be able to draw a line, so this should be:
if (renderLength <= 0) | |
if (renderLength <= 1) |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, but we may need to comment it here about why it must >=1 (and I don't know how to explain on this)
@@ -63,8 +65,10 @@ public IRenderable OffsetBy(in WVec vec) | |||
public IFinalizedRenderable PrepareRender(WorldRenderer wr) { return this; } | |||
public void Render(WorldRenderer wr) | |||
{ | |||
// Need at least 4 points to smooth the contrail over | |||
if (length - skip < 4) | |||
// Note: The length of contrail is now acutally the number of the points to draw the contrail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor spelling nit: "actually"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
fix #19084
Make contrail work for both projectile and aircraft with smoothest behavior
without solid delaysreduce solid delay to 1.And make color fade away with only alpha, not becoming white first.