View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0002538 | FSSCP | SEXPs | public | 2011-11-07 17:29 | 2012-02-21 22:17 |
Reporter | Cyborg17 | Assigned To | Eli2 | ||
Priority | normal | Severity | trivial | Reproducibility | always |
Status | resolved | Resolution | reopened | ||
Product Version | 3.6.14 RC1 | ||||
Target Version | 3.6.14 | Fixed in Version | 3.6.14 RC5 | ||
Summary | 0002538: Fade-in time limitation | ||||
Description | Similar to issue 2533, fade-in and possibly fade-out do not work correctly beyond 0001624:0009998 ms. I don't have an exact number. Attached mission shows result, where a sexp designed to completely fade in at 11 seconds will finish fading in at 0000027:0000021 seconds. | ||||
Tags | No tags attached. | ||||
2011-11-07 17:29
|
|
|
Eli2-fade-in_fade-out.patch (6,170 bytes)
Index: code/freespace2/freespace.cpp =================================================================== --- code/freespace2/freespace.cpp (revision 8233) +++ code/freespace2/freespace.cpp (working copy) @@ -4197,49 +4197,38 @@ void game_reset_shade_frame() { Fade_type = FI_NONE; - Fade_delta_time = 1.0f; gr_create_shader(&Viewer_shader, 0, 0, 0, 0); } void game_shade_frame(float frametime) { - int alpha = 0; - // only do frame shade if we are actually in a game play state if ( !game_actually_playing() ) { return; } - if (Fade_type != FI_NONE) - { - if ( (Viewer_shader.c == 0) && (Fade_type != FI_FADEOUT) ) { - return; - } + if (Fade_type != FI_NONE) { + Assert(Fade_start_timestamp > 0); + Assert(Fade_end_timestamp > 0); + Assert(Fade_end_timestamp > Fade_start_timestamp); - alpha = Viewer_shader.c; + int startAlpha = 0; + int endAlpha = 0; // Fade in or out if necessary if (Fade_type == FI_FADEOUT) { - alpha += fl2i(frametime * (255.0f / Fade_delta_time) + 0.5f); + endAlpha = 255; } else if (Fade_type == FI_FADEIN) { - alpha -= fl2i(frametime * (255.0f / Fade_delta_time) + 0.5f); + startAlpha = 255; } - // Limit and set fade type if done - if (alpha < 0) { - alpha = 0; + int duration = (Fade_end_timestamp - Fade_start_timestamp); + int elapsed = (timestamp() - Fade_start_timestamp); - if (Fade_type == FI_FADEIN) { - Fade_type = FI_NONE; - } - } + int alpha = fl2i( (float)startAlpha + (((float)endAlpha - (float)startAlpha) / (float)duration) * (float)elapsed ); - if (alpha > 255) { - alpha = 255; - - if (Fade_type == FI_FADEOUT) { - Fade_type = FI_NONE; - } + if (alpha == endAlpha) { + Fade_type = FI_NONE; } Viewer_shader.c = (ubyte)alpha; Index: code/globalincs/systemvars.cpp =================================================================== --- code/globalincs/systemvars.cpp (revision 8233) +++ code/globalincs/systemvars.cpp (working copy) @@ -36,8 +36,9 @@ //FADEIN STUFF shader Viewer_shader; -int Fade_type = FI_NONE; -float Fade_delta_time = 1.0f; +FadeType Fade_type = FI_NONE; +int Fade_start_timestamp = 0; +int Fade_end_timestamp = 0; // The detail level. Anything below zero draws simple models earlier than it // should. Anything above zero draws higher detail models longer than it should. Index: code/globalincs/systemvars.h =================================================================== --- code/globalincs/systemvars.h (revision 8233) +++ code/globalincs/systemvars.h (working copy) @@ -58,13 +58,17 @@ //-----Fadein stuff struct shader; extern shader Viewer_shader; -#define FI_NONE 0 -#define FI_FADEIN 1 -#define FI_FADEOUT 2 -extern float Fade_delta_time; -extern int Fade_type; +enum FadeType { + FI_NONE, + FI_FADEIN, + FI_FADEOUT +}; +extern FadeType Fade_type; +extern int Fade_start_timestamp; +extern int Fade_end_timestamp; + typedef struct vei { angles_t angles; // Angles defining viewer location. float distance; // Distance from which to view, plus 2x radius. Index: code/parse/sexp.cpp =================================================================== --- code/parse/sexp.cpp (revision 8233) +++ code/parse/sexp.cpp (working copy) @@ -18324,52 +18324,49 @@ void sexp_fade_in(int n) { - float delta_time = 0.0f; + int duration = 0; if(n != -1) - delta_time = eval_num(n)/1000.0f; + duration = eval_num(n); - if(delta_time > 0.0f) - { - Fade_delta_time = delta_time; + if (duration > 0) { + Fade_start_timestamp = timestamp(); + Fade_end_timestamp = timestamp(duration); Fade_type = FI_FADEIN; - } - else - { + } else { Fade_type = FI_NONE; gr_create_shader(&Viewer_shader, 0, 0, 0, 0); } // multiplayer callback multi_start_callback(); - multi_send_float(delta_time); + multi_send_int(duration); multi_end_callback(); } void multi_sexp_fade_in() { - float delta_time = 0.0f; + int duration = 0; - multi_get_float(delta_time); + multi_get_int(duration); - if(delta_time > 0.0f) { - Fade_delta_time = delta_time; + if (duration > 0) { + Fade_start_timestamp = timestamp(); + Fade_end_timestamp = timestamp(duration); Fade_type = FI_FADEIN; - } - else { + } else { Fade_type = FI_NONE; gr_create_shader(&Viewer_shader, 0, 0, 0, 0); } } -void sexp_fade_out(float delta_time, int fade_type) +void sexp_fade_out(int duration, int fadeColor) { ubyte R = 0; ubyte G = 0; ubyte B = 0; - switch(fade_type) - { + switch(fadeColor) { //White out case 1: gr_create_shader(&Viewer_shader, 255, 255, 255, Viewer_shader.c); @@ -18381,18 +18378,18 @@ //Black out default: gr_create_shader(&Viewer_shader, 0, 0, 0, Viewer_shader.c); + break; } R = Viewer_shader.r; G = Viewer_shader.g; B = Viewer_shader.b; - if(delta_time > 0.0f) { + if (duration > 0) { + Fade_start_timestamp = timestamp(); + Fade_end_timestamp = timestamp(duration); Fade_type = FI_FADEOUT; - Fade_delta_time = delta_time; - } - else - { + } else { Fade_type = FI_NONE; gr_create_shader(&Viewer_shader, R, G, B, 255); } @@ -18400,40 +18397,38 @@ void sexp_fade_out(int n) { - float delta_time = 0.0f; - int fade_type = 0; + int duration = 0; + int fadeColor = 0; - if(n != -1) - { - delta_time = eval_num(n)/1000.0f; + if (n != -1) { + duration = eval_num(n); n = CDR(n); - if(n != -1) - { - fade_type = eval_num(n); + if (n != -1) { + fadeColor = eval_num(n); } } - sexp_fade_out(delta_time, fade_type); + sexp_fade_out(duration, fadeColor); multi_start_callback(); - multi_send_float(delta_time); - multi_send_int(fade_type); + multi_send_int(duration); + multi_send_int(fadeColor); multi_end_callback(); } void multi_sexp_fade_out() { - float delta_time = 0.0f; - int fade_type; + int duration = 0; + int fadeColor = 0; - multi_get_float(delta_time); - if (!multi_get_int(fade_type)){ + multi_get_int(duration); + if (!multi_get_int(fadeColor)){ Int3(); // misformed packet return; } - sexp_fade_out(delta_time, fade_type); + sexp_fade_out(duration, fadeColor); } camera* sexp_get_set_camera(bool reset = false) |
|
Applied patch as provided by Eli2 seems to resolve the issue, would appreciate confirmation. |
|
Fix tested in Multiplayer (on both Client and SA), committed to Trunk r8369 |
|
FelixJim reported a possible issue here: http://www.hard-light.net/forums/index.php?topic=79754 |
|
|
|
Attached fix |
|
0001-Fix-looping-fade-2538.svn.patch (1,685 bytes)
Index: code/freespace2/freespace.cpp =================================================================== --- code/freespace2/freespace.cpp +++ code/freespace2/freespace.cpp @@ -4212,26 +4212,34 @@ void game_shade_frame(float frametime) Assert(Fade_end_timestamp > 0); Assert(Fade_end_timestamp > Fade_start_timestamp); - int startAlpha = 0; - int endAlpha = 0; + if( timestamp() >= Fade_start_timestamp ) { + int startAlpha = 0; + int endAlpha = 0; - // Fade in or out if necessary - if (Fade_type == FI_FADEOUT) { - endAlpha = 255; - } else if (Fade_type == FI_FADEIN) { - startAlpha = 255; - } + if (Fade_type == FI_FADEOUT) { + endAlpha = 255; + } else if (Fade_type == FI_FADEIN) { + startAlpha = 255; + } - int duration = (Fade_end_timestamp - Fade_start_timestamp); - int elapsed = (timestamp() - Fade_start_timestamp); + int alpha = 0; - int alpha = fl2i( (float)startAlpha + (((float)endAlpha - (float)startAlpha) / (float)duration) * (float)elapsed ); + if( timestamp() < Fade_end_timestamp ) { + int duration = (Fade_end_timestamp - Fade_start_timestamp); + int elapsed = (timestamp() - Fade_start_timestamp); - if (alpha == endAlpha) { - Fade_type = FI_NONE; - } + alpha = fl2i( (float)startAlpha + (((float)endAlpha - (float)startAlpha) / (float)duration) * (float)elapsed ); + } else { + //Fade finished + Fade_type = FI_NONE; + Fade_start_timestamp = 0; + Fade_end_timestamp = 0; - Viewer_shader.c = (ubyte)alpha; + alpha = endAlpha; + } + + Viewer_shader.c = (ubyte)alpha; + } } gr_flash_alpha(Viewer_shader.r, Viewer_shader.g, Viewer_shader.b, Viewer_shader.c); -- 1.7.5.4 |
|
Fix committed to trunk@8385. |
|
Fix committed to fs2_open_3_6_14@8471. |
fs2open: fs2_open_3_6_14 r8372 2012-01-25 16:37 Ported: N/A Details Diff |
Backport: Trunk 8369; From Eli2: Mantis 0002538: Fade-in time limitation. Testing in Multiplayer as well, no drastic incompatibility found. (If the host is patched but the client is not, then the timing returns are a little funny, but it doesn't cause for any crashes) |
Affected Issues 0002538 |
|
mod - /branches/fs2_open_3_6_14/code/parse/sexp.cpp | Diff File | ||
mod - /branches/fs2_open_3_6_14/code/globalincs/systemvars.h | Diff File | ||
mod - /branches/fs2_open_3_6_14/code/globalincs/systemvars.cpp | Diff File | ||
mod - /branches/fs2_open_3_6_14/code/freespace2/freespace.cpp | Diff File | ||
fs2open: trunk r8385 2012-01-28 10:48 Ported: N/A Details Diff |
Fix for Mantis 2538: From Eli2, corrects for looping fade issue reported by FelixJim. |
Affected Issues 0002538 |
|
mod - /trunk/fs2_open/code/freespace2/freespace.cpp | Diff File | ||
fs2open: fs2_open_3_6_14 r8471 2012-02-13 16:10 Ported: N/A Details Diff |
Backport: Trunk r8385; Fix for Mantis 2538: From Eli2, corrects for looping fade issue reported by FelixJim. |
Affected Issues 0002538 |
|
mod - /branches/fs2_open_3_6_14/code/freespace2/freespace.cpp | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-11-07 17:29 | Cyborg17 | New Issue | |
2011-11-07 17:29 | Cyborg17 | File Added: fadeintest.7z | |
2012-01-15 18:25 | Eli2 | Relationship added | duplicate of 0002065 |
2012-01-15 21:25 | Zacam | Assigned To | => Zacam |
2012-01-15 21:25 | Zacam | Status | new => assigned |
2012-01-15 21:26 | Zacam | File Added: Eli2-fade-in_fade-out.patch | |
2012-01-15 21:29 | Zacam | Note Added: 0013062 | |
2012-01-15 21:29 | Zacam | Status | assigned => feedback |
2012-01-24 06:54 | Zacam | Note Added: 0013147 | |
2012-01-24 06:54 | Zacam | Status | feedback => resolved |
2012-01-24 06:54 | Zacam | Resolution | open => fixed |
2012-01-25 21:37 | chief1983 | Changeset attached | => fs2open fs2_open_3_6_14 r8372 |
2012-01-27 23:33 | Eli2 | Assigned To | Zacam => Eli2 |
2012-01-27 23:33 | Eli2 | Status | resolved => feedback |
2012-01-27 23:33 | Eli2 | Resolution | fixed => reopened |
2012-01-27 23:44 | Eli2 | Note Added: 0013172 | |
2012-01-28 00:49 | FelixJim | File Added: fadeouttest.7z | |
2012-01-28 02:52 | Eli2 | File Added: 0001-Fix-looping-fade-2538.svn.patch | |
2012-01-28 02:53 | Eli2 | Note Added: 0013173 | |
2012-01-28 02:54 | Eli2 | File Deleted: 0001-Fix-looping-fade-2538.svn.patch | |
2012-01-28 02:56 | Eli2 | File Added: 0001-Fix-looping-fade-2538.svn.patch | |
2012-01-28 02:59 | Eli2 | Status | feedback => code review |
2012-01-28 15:48 | Zacam | Changeset attached | => fs2open trunk r8385 |
2012-01-28 15:48 | Zacam | Note Added: 0013180 | |
2012-01-28 15:48 | Zacam | Status | code review => resolved |
2012-02-13 21:10 | Zacam | Changeset attached | => fs2open fs2_open_3_6_14 r8471 |
2012-02-13 21:10 | Zacam | Note Added: 0013299 | |
2012-02-21 22:17 | chief1983 | Fixed in Version | => 3.6.14 RC5 |
2012-02-21 22:17 | chief1983 | Target Version | => 3.6.14 |