More code cleanups and comments; generalization of secondary planetary objects (shields, rings, atmos)
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2081 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -59,13 +59,17 @@ RotatePlanet (int x, int dx, int dy, COUNT scale_amt, UBYTE zoom_from, PRECT zoo
|
|||||||
PLANET_ORBIT *Orbit = &pSolarSysState->Orbit;
|
PLANET_ORBIT *Orbit = &pSolarSysState->Orbit;
|
||||||
int base = GSCALE_IDENTITY;
|
int base = GSCALE_IDENTITY;
|
||||||
|
|
||||||
num_frames = (pSolarSysState->pOrbitalDesc->data_index & PLANET_SHIELDED) ? 2 : 1;
|
num_frames = 1;
|
||||||
pFrame[0] = SetAbsFrameIndex (Orbit->PlanetFrameArray, (COUNT)(x + 1));
|
pFrame[0] = SetAbsFrameIndex (Orbit->PlanetFrameArray, (COUNT)(x + 1));
|
||||||
if (num_frames == 2)
|
if (Orbit->ObjectFrame)
|
||||||
pFrame[1] = Orbit->ShieldFrame;
|
{
|
||||||
|
pFrame[1] = Orbit->ObjectFrame;
|
||||||
|
num_frames++;
|
||||||
|
}
|
||||||
|
|
||||||
if (scale_amt)
|
if (scale_amt)
|
||||||
{
|
{
|
||||||
if(zoomr->extent.width)
|
if (zoomr->extent.width)
|
||||||
rp = zoomr;
|
rp = zoomr;
|
||||||
// we're zooming in, take care of scaling the frames
|
// we're zooming in, take care of scaling the frames
|
||||||
//Translate the planet so it comes from the bottom right corner
|
//Translate the planet so it comes from the bottom right corner
|
||||||
@@ -126,23 +130,25 @@ DrawPlanet (int x, int y, int dy, unsigned int rgb)
|
|||||||
s.frame = pSolarSysState->TopoFrame;
|
s.frame = pSolarSysState->TopoFrame;
|
||||||
BatchGraphics ();
|
BatchGraphics ();
|
||||||
if (! rgb)
|
if (! rgb)
|
||||||
|
{ // no tint -- just draw the surface
|
||||||
DrawStamp (&s);
|
DrawStamp (&s);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{ // apply different scan type tints
|
||||||
UBYTE r, g, b;
|
UBYTE r, g, b;
|
||||||
DWORD p;
|
DWORD p;
|
||||||
COUNT framew, frameh;
|
COUNT framew, frameh;
|
||||||
RECT srect, drect, *psrect = NULL, *pdrect = NULL;
|
RECT srect, drect, *psrect = NULL, *pdrect = NULL;
|
||||||
FRAME tintFrame[2];
|
FRAME tintFrame[2];
|
||||||
tintFrame[0] = SetAbsFrameIndex (Orbit->TintFrame, (COUNT)(1));
|
tintFrame[0] = SetAbsFrameIndex (Orbit->TintFrame, 0);
|
||||||
tintFrame[1] = SetAbsFrameIndex (Orbit->TintFrame, (COUNT)(2));
|
tintFrame[1] = SetAbsFrameIndex (Orbit->TintFrame, 1);
|
||||||
|
|
||||||
framew = GetFrameWidth (tintFrame[0]);
|
framew = GetFrameWidth (tintFrame[0]);
|
||||||
frameh = GetFrameHeight (tintFrame[0]);
|
frameh = GetFrameHeight (tintFrame[0]);
|
||||||
|
|
||||||
if (rgb != pSolarSysState->Tint_rgb)
|
if (rgb != pSolarSysState->Tint_rgb)
|
||||||
{
|
{
|
||||||
pSolarSysState->Tint_rgb=rgb;
|
pSolarSysState->Tint_rgb = rgb;
|
||||||
// Buffer the topoMap to the tintFrame;
|
// Buffer the topoMap to the tintFrame;
|
||||||
arith_frame_blit (s.frame, NULL, tintFrame[0], NULL, 0, 0);
|
arith_frame_blit (s.frame, NULL, tintFrame[0], NULL, 0, 0);
|
||||||
r = (rgb & (0x1f << 10)) >> 8;
|
r = (rgb & (0x1f << 10)) >> 8;
|
||||||
@@ -154,19 +160,22 @@ DrawPlanet (int x, int y, int dy, unsigned int rgb)
|
|||||||
p = frame_mapRGBA (tintFrame[1], r, g, b, a);
|
p = frame_mapRGBA (tintFrame[1], r, g, b, a);
|
||||||
fill_frame_rgb (tintFrame[1], p, 0, 0, 0, 0);
|
fill_frame_rgb (tintFrame[1], p, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
drect.corner.x = 0;
|
drect.corner.x = 0;
|
||||||
drect.extent.width = framew;
|
drect.extent.width = framew;
|
||||||
srect.corner.x = 0;
|
srect.corner.x = 0;
|
||||||
srect.corner.y = 0;
|
srect.corner.y = 0;
|
||||||
srect.extent.width = framew;
|
srect.extent.width = framew;
|
||||||
if (dy >= 0 && dy <= frameh) {
|
if (dy >= 0 && dy <= frameh)
|
||||||
|
{
|
||||||
drect.corner.y = dy;
|
drect.corner.y = dy;
|
||||||
drect.extent.height = 1;
|
drect.extent.height = 1;
|
||||||
pdrect = &drect;
|
pdrect = &drect;
|
||||||
srect.extent.height = 1;
|
srect.extent.height = 1;
|
||||||
psrect = &srect;
|
psrect = &srect;
|
||||||
}
|
}
|
||||||
if (dy < 0) {
|
if (dy < 0)
|
||||||
|
{
|
||||||
drect.corner.y = -dy;
|
drect.corner.y = -dy;
|
||||||
drect.extent.height = frameh + dy;
|
drect.extent.height = frameh + dy;
|
||||||
pdrect = &drect;
|
pdrect = &drect;
|
||||||
@@ -174,8 +183,8 @@ DrawPlanet (int x, int y, int dy, unsigned int rgb)
|
|||||||
psrect = &srect;
|
psrect = &srect;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dy <= frameh) {
|
if (dy <= frameh)
|
||||||
|
{
|
||||||
#ifdef USE_ADDITIVE_SCAN_BLIT
|
#ifdef USE_ADDITIVE_SCAN_BLIT
|
||||||
arith_frame_blit (tintFrame[1], psrect, tintFrame[0], pdrect, 0, -1);
|
arith_frame_blit (tintFrame[1], psrect, tintFrame[0], pdrect, 0, -1);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -247,14 +247,22 @@ FreePlanet (void)
|
|||||||
DestroyDrawable (ReleaseDrawable (Orbit->TintFrame));
|
DestroyDrawable (ReleaseDrawable (Orbit->TintFrame));
|
||||||
Orbit->TintFrame = 0;
|
Orbit->TintFrame = 0;
|
||||||
pSolarSysState->Tint_rgb = 0;
|
pSolarSysState->Tint_rgb = 0;
|
||||||
DestroyDrawable (ReleaseDrawable (Orbit->ShieldFrame));
|
|
||||||
Orbit->ShieldFrame = 0;
|
DestroyDrawable (ReleaseDrawable (Orbit->ObjectFrame));
|
||||||
|
Orbit->ObjectFrame = 0;
|
||||||
|
DestroyDrawable (ReleaseDrawable (Orbit->WorkFrame));
|
||||||
|
Orbit->WorkFrame = 0;
|
||||||
|
|
||||||
if (Orbit->lpTopoMap != 0)
|
if (Orbit->lpTopoMap != 0)
|
||||||
{
|
{
|
||||||
HFree (Orbit->lpTopoMap);
|
HFree (Orbit->lpTopoMap);
|
||||||
Orbit->lpTopoMap = 0;
|
Orbit->lpTopoMap = 0;
|
||||||
}
|
}
|
||||||
|
if (Orbit->ScratchArray != 0)
|
||||||
|
{
|
||||||
|
HFree (Orbit->ScratchArray);
|
||||||
|
Orbit->ScratchArray = 0;
|
||||||
|
}
|
||||||
|
|
||||||
DestroyContext (ReleaseContext (TaskContext));
|
DestroyContext (ReleaseContext (TaskContext));
|
||||||
TaskContext = 0;
|
TaskContext = 0;
|
||||||
|
|||||||
@@ -144,13 +144,26 @@ typedef void (*PLAN_GEN_FUNC) (BYTE control);
|
|||||||
typedef struct planet_orbit
|
typedef struct planet_orbit
|
||||||
{
|
{
|
||||||
FRAME TopoZoomFrame;
|
FRAME TopoZoomFrame;
|
||||||
|
// 4x scaled topo image for planet-side
|
||||||
PBYTE lpTopoData;
|
PBYTE lpTopoData;
|
||||||
|
// normal topo data; expressed in elevation levels
|
||||||
|
// data is signed for planets other than gas giants
|
||||||
|
// transformed to light variance map for 3d planet
|
||||||
FRAME PlanetFrameArray;
|
FRAME PlanetFrameArray;
|
||||||
|
// cached rotating 3d planet frames
|
||||||
BYTE *isPFADefined;
|
BYTE *isPFADefined;
|
||||||
FRAME ShieldFrame;
|
// cached frames 'present' flags
|
||||||
|
FRAME ObjectFrame;
|
||||||
|
// any extra planetary object (shield, atmo, rings)
|
||||||
|
// automatically drawn if present
|
||||||
FRAME TintFrame;
|
FRAME TintFrame;
|
||||||
|
// tinted topo images for current scan type (dynamic)
|
||||||
DWORD *lpTopoMap;
|
DWORD *lpTopoMap;
|
||||||
|
// RGBA version of topo image; for 3d planet
|
||||||
DWORD *ScratchArray;
|
DWORD *ScratchArray;
|
||||||
|
// temp RGBA data for whatever transforms (nuked often)
|
||||||
|
FRAME WorkFrame;
|
||||||
|
// any extra frame workspace (for dynamic objects)
|
||||||
} PLANET_ORBIT;
|
} PLANET_ORBIT;
|
||||||
|
|
||||||
// See doc/devel/generate for information on how this structure is
|
// See doc/devel/generate for information on how this structure is
|
||||||
|
|||||||
@@ -545,15 +545,19 @@ init_zoom_array (COUNT *zoom_arr)
|
|||||||
#define SHIELD_HALO_GLOW (SHIELD_GLOW_COMP + SHIELD_REFLECT_COMP)
|
#define SHIELD_HALO_GLOW (SHIELD_GLOW_COMP + SHIELD_REFLECT_COMP)
|
||||||
#define SHIELD_HALO_GLOW_MIN (SHIELD_HALO_GLOW >> 2)
|
#define SHIELD_HALO_GLOW_MIN (SHIELD_HALO_GLOW >> 2)
|
||||||
|
|
||||||
static void
|
static FRAME
|
||||||
CreateShieldMask (void)
|
CreateShieldMask (void)
|
||||||
{
|
{
|
||||||
DWORD clear, *rgba, *p_rgba;
|
DWORD clear, *rgba, *p_rgba;
|
||||||
int x, y;
|
int x, y;
|
||||||
FRAME ShieldFrame;
|
FRAME ShieldFrame;
|
||||||
|
PLANET_ORBIT *Orbit = &pSolarSysState->Orbit;
|
||||||
|
|
||||||
ShieldFrame = pSolarSysState->Orbit.ShieldFrame;
|
ShieldFrame = CaptureDrawable (
|
||||||
rgba = pSolarSysState->Orbit.ScratchArray;
|
CreateDrawable (WANT_PIXMAP | WANT_ALPHA,
|
||||||
|
SHIELD_DIAM, SHIELD_DIAM, 1));
|
||||||
|
|
||||||
|
rgba = Orbit->ScratchArray;
|
||||||
p_rgba = rgba;
|
p_rgba = rgba;
|
||||||
// This is 100% transparent.
|
// This is 100% transparent.
|
||||||
clear = frame_mapRGBA (ShieldFrame, 0, 0, 0, 0);
|
clear = frame_mapRGBA (ShieldFrame, 0, 0, 0, 0);
|
||||||
@@ -605,8 +609,13 @@ CreateShieldMask (void)
|
|||||||
SetFrameHot (ShieldFrame, MAKE_HOT_SPOT (SHIELD_RADIUS + 1,
|
SetFrameHot (ShieldFrame, MAKE_HOT_SPOT (SHIELD_RADIUS + 1,
|
||||||
SHIELD_RADIUS + 1));
|
SHIELD_RADIUS + 1));
|
||||||
|
|
||||||
{
|
return ShieldFrame;
|
||||||
// Apply the shield to the topo data
|
}
|
||||||
|
|
||||||
|
// Apply the shield to the topo data
|
||||||
|
static void
|
||||||
|
ApplyShieldTint (void)
|
||||||
|
{
|
||||||
UBYTE a;
|
UBYTE a;
|
||||||
int blit_type;
|
int blit_type;
|
||||||
FRAME tintFrame = pSolarSysState->Orbit.TintFrame;
|
FRAME tintFrame = pSolarSysState->Orbit.TintFrame;
|
||||||
@@ -624,8 +633,6 @@ CreateShieldMask (void)
|
|||||||
fill_frame_rgb (tintFrame, p, 0, 0, 0, 0);
|
fill_frame_rgb (tintFrame, p, 0, 0, 0, 0);
|
||||||
arith_frame_blit (tintFrame, NULL, pSolarSysState->TopoFrame, NULL,
|
arith_frame_blit (tintFrame, NULL, pSolarSysState->TopoFrame, NULL,
|
||||||
0, blit_type);
|
0, blit_type);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline UBYTE
|
static inline UBYTE
|
||||||
@@ -1267,16 +1274,15 @@ planet_orbit_init ()
|
|||||||
Orbit->TintFrame = CaptureDrawable (
|
Orbit->TintFrame = CaptureDrawable (
|
||||||
CreateDrawable (WANT_PIXMAP | WANT_ALPHA, (SWORD)MAP_WIDTH,
|
CreateDrawable (WANT_PIXMAP | WANT_ALPHA, (SWORD)MAP_WIDTH,
|
||||||
(SWORD)MAP_HEIGHT, 2));
|
(SWORD)MAP_HEIGHT, 2));
|
||||||
Orbit->ShieldFrame = CaptureDrawable (
|
Orbit->ObjectFrame = 0;
|
||||||
CreateDrawable (WANT_PIXMAP | WANT_ALPHA, SHIELD_DIAM,
|
Orbit->WorkFrame = 0;
|
||||||
SHIELD_DIAM, 1));
|
|
||||||
|
|
||||||
Orbit->lpTopoData = HMalloc (MAP_WIDTH * MAP_HEIGHT);
|
Orbit->lpTopoData = HMalloc (MAP_WIDTH * MAP_HEIGHT);
|
||||||
Orbit->TopoZoomFrame = CaptureDrawable (
|
Orbit->TopoZoomFrame = CaptureDrawable (
|
||||||
CreateDrawable (WANT_PIXMAP, (COUNT)(MAP_WIDTH << 2),
|
CreateDrawable (WANT_PIXMAP, (COUNT)(MAP_WIDTH << 2),
|
||||||
(COUNT)(MAP_HEIGHT << 2), 1));
|
(COUNT)(MAP_HEIGHT << 2), 1));
|
||||||
Orbit->lpTopoMap = HMalloc (sizeof (DWORD)
|
Orbit->lpTopoMap = HMalloc (sizeof (DWORD)
|
||||||
* (MAP_HEIGHT * (MAP_WIDTH + MAP_HEIGHT)));
|
* (MAP_HEIGHT * (MAP_WIDTH + MAP_HEIGHT)));
|
||||||
|
// always allocate the scratch array to largest needed size
|
||||||
Orbit->ScratchArray = HMalloc (sizeof (DWORD)
|
Orbit->ScratchArray = HMalloc (sizeof (DWORD)
|
||||||
* (SHIELD_DIAM) * (SHIELD_DIAM));
|
* (SHIELD_DIAM) * (SHIELD_DIAM));
|
||||||
}
|
}
|
||||||
@@ -1905,7 +1911,10 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, FRAME SurfDefFrame)
|
|||||||
RenderPhongMask (loc);
|
RenderPhongMask (loc);
|
||||||
|
|
||||||
if (pPlanetDesc->data_index & PLANET_SHIELDED)
|
if (pPlanetDesc->data_index & PLANET_SHIELDED)
|
||||||
CreateShieldMask ();
|
{
|
||||||
|
Orbit->ObjectFrame = CreateShieldMask ();
|
||||||
|
ApplyShieldTint ();
|
||||||
|
}
|
||||||
|
|
||||||
SetContext (OldContext);
|
SetContext (OldContext);
|
||||||
|
|
||||||
@@ -1915,6 +1924,7 @@ GeneratePlanetMask (PPLANET_DESC pPlanetDesc, FRAME SurfDefFrame)
|
|||||||
int
|
int
|
||||||
rotate_planet_task (void *data)
|
rotate_planet_task (void *data)
|
||||||
{
|
{
|
||||||
|
Task task = (Task) data;
|
||||||
SIZE i;
|
SIZE i;
|
||||||
COORD init_x;
|
COORD init_x;
|
||||||
DWORD TimeIn;
|
DWORD TimeIn;
|
||||||
@@ -1924,8 +1934,7 @@ rotate_planet_task (void *data)
|
|||||||
UBYTE zoom_from;
|
UBYTE zoom_from;
|
||||||
COUNT zoom_arr[50];
|
COUNT zoom_arr[50];
|
||||||
COUNT zoom_amt, frame_num = 0, zoom_frames;
|
COUNT zoom_amt, frame_num = 0, zoom_frames;
|
||||||
|
PLANET_ORBIT *Orbit;
|
||||||
Task task = (Task) data;
|
|
||||||
|
|
||||||
r.extent.width = 0;
|
r.extent.width = 0;
|
||||||
zooming = TRUE;
|
zooming = TRUE;
|
||||||
@@ -1936,6 +1945,7 @@ rotate_planet_task (void *data)
|
|||||||
TaskSwitch ();
|
TaskSwitch ();
|
||||||
|
|
||||||
SetPlanetTilt (pSS->SysInfo.PlanetInfo.AxialTilt);
|
SetPlanetTilt (pSS->SysInfo.PlanetInfo.AxialTilt);
|
||||||
|
Orbit = &pSolarSysState->Orbit;
|
||||||
|
|
||||||
i = 1 - ((pSS->SysInfo.PlanetInfo.AxialTilt & 1) << 1);
|
i = 1 - ((pSS->SysInfo.PlanetInfo.AxialTilt & 1) << 1);
|
||||||
init_x = (i == 1) ? (0) : (MAP_WIDTH - 1);
|
init_x = (i == 1) ? (0) : (MAP_WIDTH - 1);
|
||||||
@@ -1992,11 +2002,12 @@ rotate_planet_task (void *data)
|
|||||||
view_index++;
|
view_index++;
|
||||||
|
|
||||||
UnlockMutex (GraphicsLock);
|
UnlockMutex (GraphicsLock);
|
||||||
|
|
||||||
// If this frame hasn't been generted, generate it
|
// If this frame hasn't been generted, generate it
|
||||||
if (! pSolarSysState->Orbit.isPFADefined[x])
|
if (!Orbit->isPFADefined[x])
|
||||||
{
|
{
|
||||||
RenderLevelMasks (x);
|
RenderLevelMasks (x);
|
||||||
pSolarSysState->Orbit.isPFADefined[x] = 1;
|
Orbit->isPFADefined[x] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zooming)
|
if (zooming)
|
||||||
|
|||||||
Reference in New Issue
Block a user