2019-10-21 14:56 EDT


View Issue Details Jump to Notes ] Related Changesets ]
IDProjectCategoryView StatusLast Update
0002538FSSCPSEXPspublic2012-02-21 17:17
ReporterCyborg17 
Assigned ToEli2 
PrioritynormalSeveritytrivialReproducibilityalways
StatusresolvedResolutionreopened 
Product Version3.6.14 RC1 
Target Version3.6.14Fixed in Version3.6.14 RC5 
Summary0002538: Fade-in time limitation
DescriptionSimilar 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.
TagsNo tags attached.
Attached Files
  • 7z file icon fadeintest.7z (1,230 bytes) 2011-11-07 12:29
  • patch file icon Eli2-fade-in_fade-out.patch (6,170 bytes) 2012-01-15 16:26 -
    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)
    
    patch file icon Eli2-fade-in_fade-out.patch (6,170 bytes) 2012-01-15 16:26 +
  • 7z file icon fadeouttest.7z (1,503 bytes) 2012-01-27 19:49
  • patch file icon 0001-Fix-looping-fade-2538.svn.patch (1,685 bytes) 2012-01-27 21:56 -
    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
    
    
    patch file icon 0001-Fix-looping-fade-2538.svn.patch (1,685 bytes) 2012-01-27 21:56 +

-Relationships
duplicate of 0002065resolvedEli2 Fade in&Fade out sexp's do not work properly when the time is set beyond 5000 milliseconds 
+Relationships

-Notes

~0013062

Zacam (administrator)

Applied patch as provided by Eli2 seems to resolve the issue, would appreciate confirmation.

~0013147

Zacam (administrator)

Fix tested in Multiplayer (on both Client and SA), committed to Trunk r8369

~0013172

Eli2 (developer)

FelixJim reported a possible issue here:
http://www.hard-light.net/forums/index.php?topic=79754

~0013173

Eli2 (developer)

Attached fix

~0013180

Zacam (administrator)

Fix committed to trunk@8385.

~0013299

Zacam (administrator)

Fix committed to fs2_open_3_6_14@8471.
+Notes

+Related Changesets

-Issue History
Date Modified Username Field Change
2011-11-07 12:29 Cyborg17 New Issue
2011-11-07 12:29 Cyborg17 File Added: fadeintest.7z
2012-01-15 13:25 Eli2 Relationship added duplicate of 0002065
2012-01-15 16:25 Zacam Assigned To => Zacam
2012-01-15 16:25 Zacam Status new => assigned
2012-01-15 16:26 Zacam File Added: Eli2-fade-in_fade-out.patch
2012-01-15 16:29 Zacam Note Added: 0013062
2012-01-15 16:29 Zacam Status assigned => feedback
2012-01-24 01:54 Zacam Note Added: 0013147
2012-01-24 01:54 Zacam Status feedback => resolved
2012-01-24 01:54 Zacam Resolution open => fixed
2012-01-25 16:37 chief1983 Changeset attached => fs2open fs2_open_3_6_14 r8372
2012-01-27 18:33 Eli2 Assigned To Zacam => Eli2
2012-01-27 18:33 Eli2 Status resolved => feedback
2012-01-27 18:33 Eli2 Resolution fixed => reopened
2012-01-27 18:44 Eli2 Note Added: 0013172
2012-01-27 19:49 FelixJim File Added: fadeouttest.7z
2012-01-27 21:52 Eli2 File Added: 0001-Fix-looping-fade-2538.svn.patch
2012-01-27 21:53 Eli2 Note Added: 0013173
2012-01-27 21:54 Eli2 File Deleted: 0001-Fix-looping-fade-2538.svn.patch
2012-01-27 21:56 Eli2 File Added: 0001-Fix-looping-fade-2538.svn.patch
2012-01-27 21:59 Eli2 Status feedback => code review
2012-01-28 10:48 Zacam Changeset attached => fs2open trunk r8385
2012-01-28 10:48 Zacam Note Added: 0013180
2012-01-28 10:48 Zacam Status code review => resolved
2012-02-13 16:10 Zacam Changeset attached => fs2open fs2_open_3_6_14 r8471
2012-02-13 16:10 Zacam Note Added: 0013299
2012-02-21 17:17 chief1983 Fixed in Version => 3.6.14 RC5
2012-02-21 17:17 chief1983 Target Version => 3.6.14
+Issue History