Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Valathil on July 05, 2011, 04:28:54 pm
-
Wormhole lighting intensity is currently fixed this patch fixes this by interpolating intensity based on wormhole radius
Index: code/fireball/fireballs.cpp
===================================================================
--- code/fireball/fireballs.cpp (Revision 7324)
+++ code/fireball/fireballs.cpp (Arbeitskopie)
@@ -1044,3 +1044,27 @@
return index;
}
+
+float fireball_wormhole_intensity( object *obj )
+{
+ int num, objnum;
+ fireball *fb;
+
+ num = obj->instance;
+ objnum = OBJ_INDEX(obj);
+ Assert( Fireballs[num].objnum == objnum, "Basic sanity check. Fireballs[num].objnum (%d) should == objnum (%d)", Fireballs[num].objnum, objnum );
+
+ fb = &Fireballs[num];
+
+ float t = fb->time_elapsed;
+ float rad;
+
+ if ( t < WARPHOLE_GROW_TIME ) {
+ rad = (float)pow(t/WARPHOLE_GROW_TIME,0.4f);
+ } else if ( t < fb->total_time - WARPHOLE_GROW_TIME ) {
+ rad = 1;
+ } else {
+ rad = (float)pow((fb->total_time - t)/WARPHOLE_GROW_TIME,0.4f);
+ }
+ return rad;
+}
Index: code/fireball/fireballs.h
===================================================================
--- code/fireball/fireballs.h (Revision 7324)
+++ code/fireball/fireballs.h (Arbeitskopie)
@@ -107,6 +107,9 @@
// returns the index of the fireball bitmap for this ship. -1 if there is none.
int fireball_ship_explosion_type(ship_info *sip);
+// returns the intensity of a wormhole
+float fireball_wormhole_intensity( object *obj );
+
// internal function to draw warp grid.
extern void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_num, float radius, float life_percent, float max_radius, int warp_3d = 0 );
Index: code/object/object.cpp
===================================================================
--- code/object/object.cpp (Revision 7324)
+++ code/object/object.cpp (Arbeitskopie)
@@ -1261,11 +1261,17 @@
p = 1.0f - p;
p *= 2.0f;
-
+ float rad = p * (1.0f + frand() * 0.05f) * objp->radius;
+
+ float intensity = 1.0f;
+ if(fireball_is_warp(objp))
+ {
+ intensity = fireball_wormhole_intensity(objp); // Valathil: Get wormhole radius for lighting
+ rad = objp->radius;
+ }
// P goes from 0 to 1 to 0 over the life of the explosion
- float rad = p * (1.0f + frand() * 0.05f) * objp->radius;
-
- light_add_point( &objp->pos, rad * 2.0f, rad * 5.0f, 1.0f, r, g, b, -1 );
+
+ light_add_point( &objp->pos, rad * 2.0f, rad * 5.0f, intensity, r, g, b, -1 );
}
}
-
Please use assertions, so that the assert has a reason recorded that will be shown and please include the values involved in the assertion so that we don't need to have a debugger attached to find out what the problem with the values was. That is something like this:
+ Assertion( Fireballs[num].objnum == objnum, "Basic sanity check. Fireballs[num].objnum (%d) should == objnum (%d)", Fireballs[num].objnum, objnum);
Why is there a commented out assertion?
Why is are we committing commented out lines of code that appear to be the old version of the line above.
Why is there a commented out mprintf? If the information will not be usable in the future, please remove it. If it may be useful, use nprintf with an appropriate filter (I think we have a "lighting" filter already in use).
If there are valid reasons for the above, please note them in the code.
-
Ok great tip i just copied this code from another function in the fireball.cpp but i will update and keep in mind when using assertions in the future.
EDIT: Also fixed your other points of contention (hopefully :confused:)
-
Would possibly be nice to have mod-level control of this too, as mods with custom effects might have dimmer lighting, or is the intensity of the effect itself already taken into account? I mean, if I had a black wormhole effect for some reason, it shouldn't be giving off light right?
-
this just sets the intensity of the light in question based on the timeline of the animation so whatever you put in your color for the light is just scaled by that intensity. if you take a close look intensity was 1.0f before
-
Committed to trunk as revision 7325.