From 050ad934becd6f77ba5b1be449cab65c3809533f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 27 Aug 2009 08:34:45 +0000 Subject: [PATCH] * Automatic whitespace cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32739 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/kits/game/chart/ChartRender.cpp | 96 ++--- src/tests/kits/game/chart/ChartWindow.cpp | 448 +++++++++++----------- 2 files changed, 274 insertions(+), 270 deletions(-) diff --git a/src/tests/kits/game/chart/ChartRender.cpp b/src/tests/kits/game/chart/ChartRender.cpp index d52590b4ea..19318e82b6 100644 --- a/src/tests/kits/game/chart/ChartRender.cpp +++ b/src/tests/kits/game/chart/ChartRender.cpp @@ -1,11 +1,11 @@ /* - + ChartRender.c - + by Pierre Raynaud-Richard. - + Copyright 1998 Be Incorporated, All Rights Reserved. - + */ /* This file has been designed to be easy to compile as a stand-alone @@ -17,14 +17,14 @@ /* This table provide the horizontal and vertical offset of the matrix of pixel used for drawing stars. This matrix is designed as follow: - + -- [00] [01] [02] [03] -- [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] -- [28] [29] [30] [31] -- - + The reference pixel is [12]. */ int8 pattern_dh[32] = { -1, 0, 1, 2, @@ -68,7 +68,7 @@ static uint32 visible_mask_left[6] = { 0x8c30c308, 0x08208200 }; - + static uint32 visible_mask_right[6] = { 0xffffffff, 0xf7df7dff, @@ -77,7 +77,7 @@ static uint32 visible_mask_right[6] = { 0x10c30c31, 0x00410410, }; - + static uint32 visible_mask_top[6] = { 0xffffffff, 0xfffffff0, @@ -86,7 +86,7 @@ static uint32 visible_mask_top[6] = { 0xffc00000, 0xf0000000 }; - + static uint32 visible_mask_bottom[6] = { 0xffffffff, 0x0fffffff, @@ -95,7 +95,7 @@ static uint32 visible_mask_bottom[6] = { 0x000003ff, 0x0000000f }; - + /* Private functions used only internally. */ bool ProjectStar(star *s, geometry *geo); bool CheckClipping(star *s, buffer *buf, bool reset_clipping); @@ -108,33 +108,33 @@ void EraseStar(star *s, buffer *buf); x : -0.25, y : -0.25 x : +0.25, y : -0.25 x : -0.25, y : +0.25 - x : +0.25, y : +0.25 */ + x : +0.25, y : +0.25 */ void InitPatterns() { int32 i, j, k, count; float radius, x0, y0, x, y, dist, delta; uint8 color; uint8 *list, *color_offset; - + /* do the 4 half-pixel alignement */ for (j=0; j<4; j++) { if (j&1) x0 = 1.25; - else x0 = 0.75; + else x0 = 0.75; if (j&2) y0 = 1.25; - else y0 = 0.75; - + else y0 = 0.75; + /* do the 32 sizes */ for (i=0; i 0.5) { @@ -194,7 +194,7 @@ bool ProjectStar(star *s, geometry *geo) /* Calculate the coordinate of the star after doing the cycling operation that convert the cube of the starfield in a torus. This ensure that get the copy of the star that is the only one likely to be visible from - the camera. */ + the camera. */ x0 = s->x; if (x0 < geo->cutx) x0 += 1.0; @@ -208,7 +208,7 @@ bool ProjectStar(star *s, geometry *geo) x0 -= geo->x; y0 -= geo->y; z0 -= geo->z; - + /* Calculate the z coordinate (depth) of the star in the camera referential. */ z = geo->m[0][2]*x0 + geo->m[1][2]*y0 + geo->m[2][2]*z0; @@ -218,27 +218,27 @@ bool ProjectStar(star *s, geometry *geo) /* Calculate the x coordinate (horizontal) of the star in the camera referential. */ x = geo->m[0][0]*x0 + geo->m[1][0]*y0 + geo->m[2][0]*z0; - + /* Do the left and right clipping based on the pyramid of vision. */ if ((x < geo->xz_min*z-BORDER_CLIPPING) || (x > geo->xz_max*z+BORDER_CLIPPING)) return false; - + /* Calculate the y coordinate (vertical) of the star in the camera referential. */ y = geo->m[0][1]*x0 + geo->m[1][1]*y0 + geo->m[2][1]*z0; - + /* Do the top and bottom clipping based on the pyramid of vision. */ if ((y < geo->yz_min*z-BORDER_CLIPPING) || (y > geo->yz_max*z+BORDER_CLIPPING)) return false; - + /* Calculate the invert of z, used to project both H and V coordinate. Apply the zoom-factor at the same time. The zoom-factor was overscale by a factor of two in advance, for the half-pixel precision processing */ - inv_z = geo->zoom_factor/z; + inv_z = geo->zoom_factor/z; /* Calculate the double pixel coordinate in the buffer (in half-pixel). */ h_double = (int32)(x * inv_z + geo->offset_h); v_double = (int32)(y * inv_z + geo->offset_v); - + /* Calculate the light level of the star. We use that little weird function to a get faster gradient to black near the rear plan. */ level = (int32)(s->size * (inv_z * geo->z_max_square - z * geo->zoom_factor)) >> 8; @@ -262,8 +262,8 @@ bool ProjectStar(star *s, geometry *geo) which pixel of the star matrix are visible (if any). This depend of the clipping of the specific buffer you're using. This function will do that for the star (s), in the buffer (buf). It will return false if the star - is fully invisible, true if not. The falg reset_clipping is used to - reprocess the clipping from scratsh, or to just cumulate the new clipping + is fully invisible, true if not. The flag reset_clipping is used to + reprocess the clipping from scratch, or to just cumulate the new clipping to the last drawing clipping (this is needed when updating the clipping of every stars after changing the clipping region of the buffer). */ bool CheckClipping(star *s, buffer *buf, bool reset_clipping) @@ -295,7 +295,7 @@ bool CheckClipping(star *s, buffer *buf, bool reset_clipping) (s->v >= r->top) && (s->v <= r->bottom)) goto visible; - /* The pixel is not visible. The star is marked as not drawn. */ + /* The pixel is not visible. The star is marked as not drawn. */ invisible: s->last_draw_offset = INVALID; return false; @@ -315,7 +315,7 @@ bool CheckClipping(star *s, buffer *buf, bool reset_clipping) box.bottom = s->v + 3; /* Check if the box is fully outside of the bounding box of the clipping - region. That woudl guarantee that the star is invisible. */ + region. That woudl guarantee that the star is invisible. */ if ((box.right < buf->clip_bounds.left) || (box.left > buf->clip_bounds.right) || (box.bottom < buf->clip_bounds.top) || @@ -336,35 +336,35 @@ bool CheckClipping(star *s, buffer *buf, bool reset_clipping) tmp_visible = 0xffffffff; else tmp_visible = s->last_draw_pattern; - + /* Calculate the clipping on the left side of the rectangle. */ delta = r->left-box.left; if (delta > 5) continue; if (delta > 0) tmp_visible &= visible_mask_left[delta]; - + /* Calculate the clipping on the right side of the rectangle. */ delta = box.right-r->right; if (delta > 5) continue; if (delta > 0) tmp_visible &= visible_mask_right[delta]; - + /* Calculate the clipping on the top side of the rectangle. */ delta = r->top-box.top; if (delta > 5) continue; if (delta > 0) tmp_visible &= visible_mask_top[delta]; - + /* Calculate the clipping on the bottom side of the rectangle. */ delta = box.bottom-r->bottom; if (delta > 5) continue; if (delta > 0) tmp_visible &= visible_mask_bottom[delta]; - + /* Pixel of the matrix not clipped out at that point are visible inside this rectangle of the clipping region. We need to add them to the mask of currently known visible pixel. */ @@ -377,8 +377,8 @@ bool CheckClipping(star *s, buffer *buf, bool reset_clipping) /* If no pixel are visible, then we know... */ if (total_visible != 0) goto visible_pat; - - /* The star is not visible. It's marked as not drawn. */ + + /* The star is not visible. It's marked as not drawn. */ invisible_pat: s->last_draw_offset = INVALID; return false; @@ -436,7 +436,7 @@ void DrawStar(star *s, buffer *buf) colors = buf->colors[s->color_type]; pat_list = pattern_list[s->pattern_level]; pat_color_offset = pattern_color_offset[s->pattern_level]; - + /* Plot all pixel used to represent the star one after one... */ for (i=0; iback_color; - + /* Simple case : the star is represented by only one pixel. */ count = pattern_list_count[s->pattern_level]; if (count == 1) { @@ -507,7 +507,7 @@ void EraseStar(star *s, buffer *buf) /* Complex case : the star is represented by a multiple pixels. */ else { pat_list = pattern_list[s->pattern_level]; - + /* Erase all pixel used to represent the star one after one... */ for (i=0; icount = max_c(sp->count, 0); + sp->count = max_c(sp->count, 0); /* Calculate the number of stars that were process during the previous frame and still need to be process for that frame. */ min_count = sp->erase_count; if (sp->count < min_count) min_count = sp->count; - + s = sp->list; - + /* For all those star... */ for (i=0; ilast_draw_offset = INVALID; } - + /* For star that were process at the previous frame but that we don't want to process anymore, we just need to erase them. */ - for (; ierase_count; s++, i++) + for (; ierase_count; s++, i++) { if (s->last_draw_offset != INVALID) EraseStar(s, buf); - + } + /* For star that were not process before, but are now, we just need to go through the projection, clipping and drawing steps. */ for (; icount; s++, i++) { @@ -602,9 +603,10 @@ void RefreshClipping(buffer *buf, star_packet *sp) int32 i; s = sp->list; - for (i=0; ierase_count; s++, i++) + for (i=0; ierase_count; s++, i++) { if (s->last_draw_offset != INVALID) CheckClipping(s, buf, false); + } } diff --git a/src/tests/kits/game/chart/ChartWindow.cpp b/src/tests/kits/game/chart/ChartWindow.cpp index 10ed4430ec..2ab1cefbef 100644 --- a/src/tests/kits/game/chart/ChartWindow.cpp +++ b/src/tests/kits/game/chart/ChartWindow.cpp @@ -1,11 +1,11 @@ /* - + ChartWindow.cpp - + by Pierre Raynaud-Richard. - + Copyright 1998 Be Incorporated, All Rights Reserved. - + */ #include "ChartWindow.h" @@ -116,7 +116,7 @@ enum { WINDOW_V_STD = 600, WINDOW_H_MAX = 1920, WINDOW_V_MAX = 1440, - + /* increment step used to dynamically resize the offscreen buffer */ WINDOW_H_STEP = 224, WINDOW_V_STEP = 168 @@ -301,14 +301,14 @@ TMatrix::Set(const float alpha, const float theta, const float phi) void LaunchSound() { -/* +/* BEntry soundFile; app_info info; status_t err; entry_ref snd_ref; BDirectory appFolder; - sound_handle sndhandle; - + sound_handle sndhandle; + err = be_app->GetAppInfo(&info); BEntry appEntry(&info.ref); if (err != B_NO_ERROR) @@ -374,7 +374,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) BFont boldFont(be_bold_font); if (boldFont.Size() > MAX_FONT_SIZE) boldFont.SetSize(MAX_FONT_SIZE); - + /* offset the content area frame in window relative coordinate */ frame.OffsetTo(0.0, 0.0); @@ -406,7 +406,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) fCurrentSettings.back_color.alpha = 255; fCurrentSettings.star_density = STAR_DENSITY_DEFAULT; fCurrentSettings.refresh_rate = REFRESH_RATE_DEFAULT; - BScreen screen(this); + BScreen screen(this); fCurrentSettings.depth = screen.ColorSpace(); fCurrentSettings.width = (int32)frame.right+1-LEFT_WIDTH; fCurrentSettings.height = (int32)frame.bottom+1-TOP_LEFT_LIMIT; @@ -448,7 +448,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) fSpeed = 0.0115; fTargetSpeed = fSpeed; - /* initialise the view coordinate system */ + /* initialise the view coordinate system */ InitGeometry(); SetGeometry(fCurrentSettings.width, fCurrentSettings.height); SetCubeOffset(); @@ -470,7 +470,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) /* build the UI content of the window */ /* top line background */ - r.Set(0.0, 0.0, frame.right, TOP_LEFT_LIMIT - 1); + r.Set(0.0, 0.0, frame.right, TOP_LEFT_LIMIT - 1); fTopView = new BView(r, "top view", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW); fTopView->SetViewColor(background_color); AddChild(fTopView); @@ -478,7 +478,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) h = 2; v = V_BORDER; - /* instant load vue-meter */ + /* instant load vue-meter */ r.Set(h, v, h+INSTANT_LOAD-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER)); fInstantLoad = new InstantView(r); fTopView->AddChild(fInstantLoad); @@ -564,7 +564,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) h += BUTTON_WIDTH+2*H_BORDER; - /* background color button */ + /* background color button */ r.Set(h, v, h+BUTTON_WIDTH-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER)); fColorButton = new BPictureButton(r, "", ButtonPicture(false, COLOR_BUTTON_PICT), @@ -576,7 +576,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) h += BUTTON_WIDTH+2*H_BORDER; - /* star density button */ + /* star density button */ r.Set(h, v, h+BUTTON_WIDTH-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER)); fDensityButton = new BPictureButton(r, "", ButtonPicture(false, DENSITY_BUTTON_PICT), @@ -588,7 +588,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) h += BUTTON_WIDTH+H_BORDER; - /* starfield type popup */ + /* starfield type popup */ menu = new BPopUpMenu("Chaos"); item = new BMenuItem("Chaos", new BMessage(SPACE_CHAOS_MSG)); item->SetTarget(this); @@ -599,7 +599,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) item = new BMenuItem("Spiral", new BMessage(SPACE_SPIRAL_MSG)); item->SetTarget(this); menu->AddItem(item); - + r.Set(h, v, h+SPACE_LABEL+SPACE_POPUP-1, v + (TOP_LEFT_LIMIT - 1 - 2*V_BORDER)); popup = new BMenuField(r, "", "Space:", menu); popup->SetFont(&font); @@ -608,11 +608,11 @@ ChartWindow::ChartWindow(BRect frame, const char *name) popup->ResizeToPreferred(); popup->SetDivider(popup->StringWidth(popup->Label()) + 4.0f); fTopView->AddChild(popup); - + h += SPACE_LABEL+SPACE_POPUP+2*H_BORDER; - + /* left column gray background */ - r.Set(0.0, TOP_LEFT_LIMIT, LEFT_WIDTH - 1, frame.bottom); + r.Set(0.0, TOP_LEFT_LIMIT, LEFT_WIDTH - 1, frame.bottom); fLeftView = new BView(r, "top view", B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW); fLeftView->SetViewColor(background_color); AddChild(fLeftView); @@ -621,8 +621,8 @@ ChartWindow::ChartWindow(BRect frame, const char *name) v2 = LEFT_OFFSET; h = h2; v = v2; - - /* status box */ + + /* status box */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2, v+STATUS_BOX-1); fStatusBox = new BBox(r); fStatusBox->SetFont(&boldFont); @@ -631,8 +631,8 @@ ChartWindow::ChartWindow(BRect frame, const char *name) float boxWidth, boxHeight; fStatusBox->GetPreferredSize(&boxWidth, &boxHeight); boxWidth += r.left; - - h = BOX_H_OFFSET; + + h = BOX_H_OFFSET; v = BOX_V_OFFSET; /* frames per second title string */ @@ -676,7 +676,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) v2 += STATUS_BOX+LEFT_OFFSET*2; h = h2; v = v2; - + /* Fullscreen mode check box */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-1, v+FULL_SCREEN-1); full_screen = new BCheckBox(r, "", "Full Screen", new BMessage(FULL_SCREEN_MSG)); @@ -688,11 +688,11 @@ ChartWindow::ChartWindow(BRect frame, const char *name) full_screen->GetPreferredSize(&width, &height); boxWidth = max_c(width + r.left, boxWidth); fLeftView->AddChild(full_screen); - + v2 += FULL_SCREEN+LEFT_OFFSET*2; h = h2; v = v2; - + /* Automatic demonstration activation button */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-1, v+AUTO_DEMO-1); button = new BButton(r, "", "Auto demo", new BMessage(AUTO_DEMO_MSG)); @@ -701,10 +701,10 @@ ChartWindow::ChartWindow(BRect frame, const char *name) button->GetPreferredSize(&width, &height); boxWidth = max_c(width + r.left, boxWidth); fLeftView->AddChild(button); - + v2 += AUTO_DEMO+LEFT_OFFSET*2; h = h2; - v = v2; + v = v2; /* Enabling second thread check box */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-1, v+SECOND_THREAD-1); @@ -713,7 +713,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) check_box->SetFont(&font); check_box->ResizeToPreferred(); fLeftView->AddChild(check_box); - + v2 += SECOND_THREAD+LEFT_OFFSET*2 + 2; h = h2; v = v2; @@ -725,67 +725,67 @@ ChartWindow::ChartWindow(BRect frame, const char *name) fColorsBox->SetFont(&boldFont); fLeftView->AddChild(fColorsBox); - h = BOX_H_OFFSET; + h = BOX_H_OFFSET; v = BOX_V_OFFSET; - /* star color red check box */ + /* star color red check box */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); check_box = new BCheckBox(r, "", "Red", new BMessage(COLORS_RED_MSG)); check_box->SetFont(&font); check_box->ResizeToPreferred(); fColorsBox->AddChild(check_box); - + v += COLORS_LABEL+COLORS_OFFSET; - - /* star color green check box */ + + /* star color green check box */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); check_box = new BCheckBox(r, "", "Green", new BMessage(COLORS_GREEN_MSG)); check_box->SetValue(1); check_box->SetFont(&font); check_box->ResizeToPreferred(); fColorsBox->AddChild(check_box); - + v += COLORS_LABEL+COLORS_OFFSET; - - /* star color blue check box */ + + /* star color blue check box */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); check_box = new BCheckBox(r, "", "Blue", new BMessage(COLORS_BLUE_MSG)); check_box->SetValue(1); check_box->SetFont(&font); check_box->ResizeToPreferred(); fColorsBox->AddChild(check_box); - + v += COLORS_LABEL+COLORS_OFFSET; - - /* star color yellow check box */ + + /* star color yellow check box */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); check_box = new BCheckBox(r, "", "Yellow", new BMessage(COLORS_YELLOW_MSG)); check_box->SetValue(1); check_box->SetFont(&font); check_box->ResizeToPreferred(); fColorsBox->AddChild(check_box); - + v += COLORS_LABEL+COLORS_OFFSET; - - /* star color orange check box */ + + /* star color orange check box */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); check_box = new BCheckBox(r, "", "Orange", new BMessage(COLORS_ORANGE_MSG)); check_box->SetFont(&font); check_box->ResizeToPreferred(); fColorsBox->AddChild(check_box); - + v += COLORS_LABEL+COLORS_OFFSET; - - /* star color pink check box */ + + /* star color pink check box */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); check_box = new BCheckBox(r, "", "Pink", new BMessage(COLORS_PINK_MSG)); check_box->SetFont(&font); check_box->ResizeToPreferred(); fColorsBox->AddChild(check_box); - + v += COLORS_LABEL+COLORS_OFFSET; - - /* star color white check box */ + + /* star color white check box */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); check_box = new BCheckBox(r, "", "White", new BMessage(COLORS_WHITE_MSG)); check_box->SetFont(&font); @@ -803,38 +803,38 @@ ChartWindow::ChartWindow(BRect frame, const char *name) fSpecialBox->SetLabel("Special"); fLeftView->AddChild(fSpecialBox); - h = BOX_H_OFFSET; + h = BOX_H_OFFSET; v = BOX_V_OFFSET; - /* no special radio button */ + /* no special radio button */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); radio = new BRadioButton(r, "", "None", new BMessage(SPECIAL_NONE_MSG)); radio->SetValue(1); radio->SetFont(&font); radio->ResizeToPreferred(); fSpecialBox->AddChild(radio); - + v += COLORS_LABEL+COLORS_OFFSET; - - /* comet special animation radio button */ + + /* comet special animation radio button */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); radio = new BRadioButton(r, "", "Comet", new BMessage(SPECIAL_COMET_MSG)); radio->SetFont(&font); radio->ResizeToPreferred(); fSpecialBox->AddChild(radio); - + v += COLORS_LABEL+COLORS_OFFSET; - - /* novas special animation radio button */ + + /* novas special animation radio button */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); radio = new BRadioButton(r, "", "Novas", new BMessage(SPECIAL_NOVAS_MSG)); radio->SetFont(&font); radio->ResizeToPreferred(); fSpecialBox->AddChild(radio); - + v += COLORS_LABEL+COLORS_OFFSET; - - /* space batle special animation radio button (not implemented) */ + + /* space batle special animation radio button (not implemented) */ r.Set(h, v, h+LEFT_WIDTH-2*LEFT_OFFSET-2*BOX_H_OFFSET-1, v+COLORS_LABEL-1); radio = new BRadioButton(r, "", "Battle", new BMessage(SPECIAL_BATTLE_MSG)); radio->SetEnabled(false); @@ -850,7 +850,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) fChartView = new ChartView(r); fChartView->SetViewColor(0, 0, 0); AddChild(fChartView); - + /* allocate the semaphores */ fDrawingLock = create_sem(1, "chart locker"); fSecondThreadLock = create_sem(0, "chart second locker"); @@ -861,7 +861,7 @@ ChartWindow::ChartWindow(BRect frame, const char *name) fAnimationThread = spawn_thread(ChartWindow::Animation, "chart animation", B_NORMAL_PRIORITY, (void*)this); - + fSecondAnimationThread = spawn_thread(ChartWindow::Animation2, "chart animation2", B_NORMAL_PRIORITY, (void*)this); @@ -876,19 +876,19 @@ ChartWindow::~ChartWindow() /* setting this flag force both animation threads to quit */ fKillThread = true; - + /* wait for the two animation threads to quit */ - wait_for_thread(fAnimationThread, &result); - wait_for_thread(fSecondAnimationThread, &result); + wait_for_thread(fAnimationThread, &result); + wait_for_thread(fSecondAnimationThread, &result); /* free the offscreen bitmap if any */ delete fOffscreen; - + /* release the semaphores used for synchronisation */ delete_sem(fDrawingLock); delete_sem(fSecondThreadLock); delete_sem(fSecondThreadRelease); - + /* free the buffers used to store the starlists */ free(fStars.list); free(fSpecials.list); @@ -896,7 +896,7 @@ ChartWindow::~ChartWindow() } -// #pragma mark Standard window members +// #pragma mark Standard window members bool @@ -914,7 +914,7 @@ ChartWindow::MessageReceived(BMessage *message) BHandler *handler; BCheckBox *check_box; BSlider *slider; - + message->FindPointer("source", (void**)&handler); switch(message->what) { /* This is a key part of the architecture. MessageReceived is @@ -1021,7 +1021,7 @@ ChartWindow::MessageReceived(BMessage *message) /* open the three floating window used to do live setting of some advanced parameters. Those windows will return live feedback that will be executed by some of the previous - messages. */ + messages. */ case OPEN_COLOR_MSG : OpenColorPalette(BPoint(200.0, 200.0)); break; @@ -1045,7 +1045,7 @@ ChartWindow::ScreenChanged(BRect screen_size, color_space depth) /* this is the same principle than the one described for MessageReceived, to inform the engine that the depth of the screen changed (needed only for offscreen bitmap. - In DirectWindow, you get a direct notification). */ + In DirectWindow, you get a direct notification). */ fNextSettings.depth = BScreen(this).ColorSpace(); } @@ -1056,9 +1056,9 @@ ChartWindow::FrameResized(float new_width, float new_height) /* this is the same principle than the one described for MessageReceived, to inform the engine that the window size changed (needed only for offscreen bitmap. In - DirectWindow, you get a direct notification). */ + DirectWindow, you get a direct notification). */ fNextSettings.width = (int32)Frame().Width()+1-LEFT_WIDTH; - fNextSettings.height = (int32)Frame().Height()+1-TOP_LEFT_LIMIT; + fNextSettings.height = (int32)Frame().Height()+1-TOP_LEFT_LIMIT; } @@ -1072,7 +1072,7 @@ ChartWindow::GetAppWindow(const char *name) { int32 index; BWindow *window; - + for (index = 0;; index++) { window = be_app->WindowAt(index); if (window == NULL) @@ -1085,7 +1085,7 @@ ChartWindow::GetAppWindow(const char *name) window->Unlock(); } } - return window; + return window; } /* this function return a picture (in active or inactive state) of @@ -1101,7 +1101,7 @@ ChartWindow::ButtonPicture(bool active, int32 button_type) BPicture *pict; - /* create and open the picture */ + /* create and open the picture */ pict = new BPicture(); r = fOffwindowButton->Bounds(); fOffwindowButton->SetValue(active); @@ -1121,7 +1121,7 @@ ChartWindow::ButtonPicture(bool active, int32 button_type) else if (button_type == DENSITY_BUTTON_PICT) { /* this button just contains a big string (using a bigger font size than what a standard BButton would allow) with the current value - of the star density pourcentage. */ + of the star density pourcentage. */ value = (fCurrentSettings.star_density*100 + STAR_DENSITY_MAX/2) / STAR_DENSITY_MAX; sprintf(word, "%3ld", value); draw_string: @@ -1129,12 +1129,12 @@ ChartWindow::ButtonPicture(bool active, int32 button_type) fOffwindowButton->SetFontSize(14.0); delta.x = BUTTON_WIDTH/2-(fOffwindowButton->StringWidth(word) * 0.5); delta.y = (TOP_LEFT_LIMIT-2*V_BORDER)/2 + 6.0; - fOffwindowButton->DrawString(word, delta); + fOffwindowButton->DrawString(word, delta); } else { /* this button just contains a big string (using a bigger font size than what a standard BButton would allow) with the current value - of the target refresh rate in frames per second. */ + of the target refresh rate in frames per second. */ sprintf(word, "%3.1f", fCurrentSettings.refresh_rate + 0.05); goto draw_string; } @@ -1219,7 +1219,7 @@ ChartWindow::OpenRefresh(BPoint here) BSlider *slider = new BSlider(frame, "", NULL, new BMessage(REFRESH_RATE_MSG), 0, 1000); slider->SetViewColor(background_color); slider->SetTarget(NULL, this); - slider->SetValue((int32)(1000 * log(fCurrentSettings.refresh_rate / REFRESH_RATE_MIN) / + slider->SetValue((int32)(1000 * log(fCurrentSettings.refresh_rate / REFRESH_RATE_MIN) / log(REFRESH_RATE_MAX/REFRESH_RATE_MIN))); slider->SetModificationMessage(new BMessage(REFRESH_RATE_MSG)); slider->SetLimitLabels(" 0.6 f/s (logarythmic scale)", "600.0 f/s"); @@ -1237,15 +1237,15 @@ ChartWindow::DrawInstantLoad(float frame_per_second) { int32 i; bigtime_t timeout; - + int32 level = (int32)((frame_per_second + 6.0) * (1.0/12.0)); if (level > 50) level = 50; - /* if the load level is inchanged, nothing more to do... */ + /* if the load level is inchanged, nothing more to do... */ if (level == fInstantLoadLevel) return; - + /* We need to lock the window to be able to draw that. But as some BControl are still synchronous, if the user is still tracking them, the window can stay block for a long time. It's not such a big deal @@ -1259,9 +1259,9 @@ ChartWindow::DrawInstantLoad(float frame_per_second) timeout = 0; if (LockWithTimeout(timeout) != B_OK) return; - + /* the new level is higher than the previous. We need to draw more - colored bars. */ + colored bars. */ if (level > fInstantLoadLevel) { for (i = fInstantLoadLevel; i < level; i++) { if (i < fInstantLoad->step) @@ -1281,7 +1281,7 @@ ChartWindow::DrawInstantLoad(float frame_per_second) } /* we want that drawing to be completed as soon as possible */ Flush(); - + fInstantLoadLevel = level; Unlock(); } @@ -1297,7 +1297,7 @@ ChartWindow::PrintStatNumbers(float fps) /* rules use to determine the stat numbers : if the target framerate is greater than the simulate one, then we consider that 100.0 cpu - was used, and we only got the simulate framerate. */ + was used, and we only got the simulate framerate. */ if (fps <= fCurrentSettings.refresh_rate) { load = 100.0; frame_rate = fps + 0.05; @@ -1310,7 +1310,7 @@ ChartWindow::PrintStatNumbers(float fps) load = (100.0*fCurrentSettings.refresh_rate)/fps + 0.05; frame_rate = fCurrentSettings.refresh_rate + 0.05; } - + /* convert numbers in strings */ sprintf(text_cpu_load, "%3.1f", load); sprintf(text_frames, "%3.1f", frame_rate); @@ -1321,7 +1321,7 @@ ChartWindow::PrintStatNumbers(float fps) timeout = 100000; else timeout = 0; - + if (LockWithTimeout(timeout) == B_OK) { fFramesView->SetText(text_frames); fCpuLoadView->SetText(text_cpu_load); @@ -1336,19 +1336,19 @@ ChartWindow::PrintStatNumbers(float fps) void ChartWindow::InitGeometry() { - /* calculate some parameters required for the 3d processing */ + /* calculate some parameters required for the 3d processing */ float dz = sqrt(1.0 - (DH_REF*DH_REF + DV_REF*DV_REF) * (0.5 + 0.5/Z_CUT_RATIO) * (0.5 + 0.5/Z_CUT_RATIO)); fDepthRef = dz / (1.0 - 1.0/Z_CUT_RATIO); - + /* set the position of the pyramid of vision, so that it was always possible to include it into a 1x1x1 cube parallel to the 3 main axis. */ fGeometry.z_max = fDepthRef; fGeometry.z_min = fDepthRef/Z_CUT_RATIO; - + /* used for lighting processing */ fGeometry.z_max_square = fGeometry.z_max * fGeometry.z_max; - + /* preprocess that for the fast clipping based on the pyramid of vision */ fGeometry.xz_max = (0.5*DH_REF)/fGeometry.z_max; fGeometry.xz_min = -fGeometry.xz_max; @@ -1400,7 +1400,7 @@ ChartWindow::ChangeSetting(setting new_set) break; } } - + /* check for change in the target refresh rate */ if (fCurrentSettings.refresh_rate != new_set.refresh_rate) { fCurrentSettings.refresh_rate = new_set.refresh_rate; @@ -1419,7 +1419,7 @@ ChartWindow::ChangeSetting(setting new_set) if (fCurrentSettings.animation != ANIMATION_OFF) fFrameDelay = (bigtime_t)(1000000.0/new_set.refresh_rate); } - + /* check for change in the star colors list */ for (i=0; i<7; i++) if (fCurrentSettings.colors[i] != new_set.colors[i]) { @@ -1435,7 +1435,7 @@ ChartWindow::ChangeSetting(setting new_set) SetStarColors(color_index, color_count); break; } - + /* check for change of the special effect setting */ if (new_set.special != fCurrentSettings.special) InitSpecials(new_set.special); @@ -1446,7 +1446,7 @@ ChartWindow::ChangeSetting(setting new_set) /* check the settings of the offscreen bitmap */ CheckBitmap(new_set.depth, new_set.width, new_set.height); /* synchronise the camera geometry and the offscreen buffer geometry */ - SetGeometry(fBitmapBuffer.buffer_width, fBitmapBuffer.buffer_height); + SetGeometry(fBitmapBuffer.buffer_width, fBitmapBuffer.buffer_height); /* reset the offscreen background and cancel the erasing */ SetBitmapBackGround(); fStars.erase_count = 0; @@ -1464,7 +1464,7 @@ ChartWindow::ChangeSetting(setting new_set) release_sem(fDrawingLock); } } - + /* check for change of the animation mode. */ if (new_set.animation != fCurrentSettings.animation) { /* when there is no camera animation, we loop only @@ -1483,21 +1483,21 @@ ChartWindow::ChangeSetting(setting new_set) fCountPhi = 0; } } - + /* check for change of starfield model */ if (new_set.space_model != fCurrentSettings.space_model) { /* Generate a new starfield. Also reset the special animation */ InitStars(new_set.space_model); InitSpecials(new_set.special); } - + /* check for change of the background color */ if ((new_set.back_color.red != fCurrentSettings.back_color.red) || (new_set.back_color.green != fCurrentSettings.back_color.green) || (new_set.back_color.blue != fCurrentSettings.back_color.blue)) { if (LockWithTimeout(200000) == B_OK) { - BScreen screen(this); - /* set the background color and it's 8 bits index equivalent */ + BScreen screen(this); + /* set the background color and it's 8 bits index equivalent */ fCurrentSettings.back_color = new_set.back_color; fBackColorIndex = screen.IndexForColor(new_set.back_color); /* set the nackground color of the view (directwindow mode) */ @@ -1515,7 +1515,7 @@ ChartWindow::ChangeSetting(setting new_set) release_sem(fDrawingLock); /* in offscreen mode, erase the background and cancel star erasing */ if (new_set.display == DISPLAY_BITMAP) { - SetBitmapBackGround(); + SetBitmapBackGround(); fStars.erase_count = 0; fSpecials.erase_count = 0; } @@ -1525,7 +1525,7 @@ ChartWindow::ChangeSetting(setting new_set) Unlock(); } } - + /* check for change of the star animation density */ if (new_set.star_density != fCurrentSettings.star_density) { if (LockWithTimeout(200000) == B_OK) { @@ -1535,10 +1535,10 @@ ChartWindow::ChangeSetting(setting new_set) fDensityButton->SetEnabledOn(ButtonPicture(true, DENSITY_BUTTON_PICT)); fDensityButton->Invalidate(); Unlock(); - } + } fStars.count = new_set.star_density; } - + /* check for change in the buffer format for the offscreen bitmap. DirectWindow depth change are always handle in realtime */ if (new_set.depth != fCurrentSettings.depth) { @@ -1550,17 +1550,17 @@ ChartWindow::ChangeSetting(setting new_set) fSpecials.erase_count = 0; } } - + /* check for change in the drawing area of the offscreen bitmap */ if ((new_set.width != fCurrentSettings.width) || (new_set.height != fCurrentSettings.height)) { CheckBitmap(new_set.depth, new_set.width, new_set.height); fBitmapBuffer.buffer_width = new_set.width; fBitmapBuffer.buffer_height = new_set.height; if (new_set.display == DISPLAY_BITMAP) - SetGeometry(fBitmapBuffer.buffer_width, fBitmapBuffer.buffer_height); + SetGeometry(fBitmapBuffer.buffer_width, fBitmapBuffer.buffer_height); SetBitmapClipping(new_set.width, new_set.height); } - + /* copy the new state as the new current state */ fCurrentSettings.Set(&new_set); } @@ -1576,7 +1576,7 @@ ChartWindow::InitStars(int32 space_model) float factor[8]; uint32 i, index, i_step; TPoint amas[8]; - + switch (space_model) { /* Create a random starfield */ case SPACE_CHAOS : @@ -1601,12 +1601,12 @@ ChartWindow::InitStars(int32 space_model) /* make each amas ramdomly smaller or bigger */ for (i=8; i<32; i++) { amas_select[i] = (fCrcAlea & 7); - CrcStep(); + CrcStep(); } - + /* create a random starfield */ FillStarList(fStars.list, STAR_DENSITY_MAX); - + /* In spiral mode, only half the star will be put into the amas. the other half will be put into the spiral galaxy. */ if (space_model == SPACE_AMAS) @@ -1628,7 +1628,7 @@ ChartWindow::InitStars(int32 space_model) dz = s->z-amas[index].z; if (dz < -0.5) dz += 1.0; if (dz > 0.5) dz -= 1.0; - + /* make the star randomly closer from its center, but keep it on the same orientation. */ step = 0; @@ -1658,9 +1658,9 @@ ChartWindow::InitStars(int32 space_model) s->z = amas[index].z + dz; if (s->z >= 1.0) s->z -= 1.0; if (s->z <= 0.0) s->z += 1.0; - + s += i_step; - } + } /* record the center of the amas as key points for the free camera animation mode. */ @@ -1668,7 +1668,7 @@ ChartWindow::InitStars(int32 space_model) fKeyPoints[i] = amas[i]; fKeyPointCount = 8; - /* no further processing needed in amas only mode. */ + /* no further processing needed in amas only mode. */ if (space_model == SPACE_AMAS) break; @@ -1684,7 +1684,7 @@ ChartWindow::InitStars(int32 space_model) dx = s->x - 0.5; dy = s->y - 0.5; dz = s->z - 0.5; - + /* make the star randomly closer from its center, but keep it on the same orientation. */ step = 0; @@ -1693,7 +1693,7 @@ ChartWindow::InitStars(int32 space_model) dist *= 0.5; step++; } - + step -= (fCrcAlea&3); CrcStep(); fact = 0.5; @@ -1717,7 +1717,7 @@ ChartWindow::InitStars(int32 space_model) dz = sin(alpha) * r; } CrcStep(); - + /* put the star back in the [0-1]x[0-1]x[0-1] iteration of the cubic torus. */ s->x = 0.5 + dx; @@ -1741,7 +1741,7 @@ ChartWindow::InitStars(int32 space_model) break; } - /* In all starfield modes, for all stars, peek a random brightness level */ + /* In all starfield modes, for all stars, peek a random brightness level */ for (i=0; i>8) & 1023) * (6.283159/1024.0); CrcStep(); - + /* pick a random ejection speed */ coeff = 0.000114 + 0.0000016 * (float)((fCrcAlea>>17) & 31); if ((fCrcAlea & 7) > 4) coeff *= 0.75; if ((fCrcAlea & 7) == 7) coeff *= 0.65; CrcStep(); - + /* calculate the ejection speed vector */ ksin = sin(alpha) * coeff; kcos = cos(alpha) * coeff; @@ -1836,7 +1836,7 @@ ChartWindow::InitSpecials(int32 code) } } break; - + /* Add a list of random star (used for nova effect by modifying their brightness level in real time) close from the first stars of the starfield. */ @@ -1856,7 +1856,7 @@ ChartWindow::InitSpecials(int32 code) } break; - /* not implemented */ + /* not implemented */ case SPECIAL_BATTLE : fSpecials.count = 0; break; @@ -1869,7 +1869,7 @@ void ChartWindow::SetStarColors(int32 *color_list, int32 color_count) { int32 i, index; - + index = 0; for (i=0; ibytes_per_pixel = 1; break; } - + /* Check if the endianess of the buffer is different from the endianess use by the processor to encode the color information */ switch (depth) { @@ -2002,10 +2002,10 @@ ChartWindow::SetColorSpace(buffer *buf, color_space depth) swap_needed = false; break; } - + #if B_HOST_IS_BENDIAN swap_needed = ~swap_needed; -#endif +#endif /* fill the color tables (8 light level for 7 colors, and also encode the background color */ col = buf->colors[0]; @@ -2067,7 +2067,7 @@ ChartWindow::SetColorSpace(buffer *buf, color_space depth) */ void ChartWindow::SetPatternBits(buffer *buf) -{ +{ for (int32 i=0; i<32; i++) { buf->pattern_bits[i] = (void*)((char*)buf->bits + buf->bytes_per_row * pattern_dv[i] + @@ -2094,13 +2094,13 @@ ChartWindow::Animation(void *data) bigtime_t before_frame, after_frame, fps; bigtime_t last_4_frames[4]; ChartWindow *w; - + w = (ChartWindow*)data; - + /* init refresh rate control */ timer = system_time(); w->fFrameDelay = 100000; - + /* init performance timing control variables */ next_stat = timer + STAT_DELAY; cur_4_frames_index = 0; @@ -2109,16 +2109,16 @@ ChartWindow::Animation(void *data) last_fps[i] = 0.0; total_fps = 0.0; count_fps = 0; - + /* here start the loop doing all the good stuff */ while (!w->fKillThread) { - - /* start the performance mesurement here */ + + /* start the performance mesurement here */ before_frame = system_time(); - + /* credit the timer by the current delay between frame */ timer += w->fFrameDelay; - + /* change the settings, if needed */ w->ChangeSetting(w->fNextSettings); @@ -2137,17 +2137,19 @@ ChartWindow::Animation(void *data) done to avoid any potential deadlock. */ while (acquire_sem(w->fDrawingLock) == B_INTERRUPTED) ; + if (w->fDirectConnected) w->RefreshStars(&w->fDirectBuffer, time_factor * 2.4); + release_sem(w->fDrawingLock); } /* do the camera animation */ w->CameraAnimation(time_factor); - /* end the performance mesurement here */ + /* end the performance mesurement here */ after_frame = system_time(); - + /* performance timing calculation here (if display enabled). */ if (w->fCurrentSettings.display != DISPLAY_OFF) { /* record frame duration into a 2 levels 4 entries ring buffer */ @@ -2158,16 +2160,16 @@ ChartWindow::Animation(void *data) last_fps[cur_last_fps++ & 3] = last_4_frames[0]+last_4_frames[1]+last_4_frames[2]+last_4_frames[3]; /* the instant load is calculated based on the average duration - of the last 16 frames. */ + of the last 16 frames. */ fps = (bigtime_t) (16e6 / (last_fps[0]+last_fps[1]+last_fps[2]+last_fps[3])); w->DrawInstantLoad(fps); - + total_fps += fps; count_fps += 1; - + /* The statistic numbers are based on the ratio between the real duration and the frame count during a period of approximately - STAT_DELAY microseconds. */ + STAT_DELAY microseconds. */ if (after_frame > next_stat) { w->PrintStatNumbers(total_fps/(float)count_fps); next_stat = after_frame+STAT_DELAY; @@ -2176,7 +2178,7 @@ ChartWindow::Animation(void *data) } } } - + /* do a pause if necessary */ current = system_time(); time_left = timer-current; @@ -2189,7 +2191,7 @@ ChartWindow::Animation(void *data) /* this factor controls the dynamic timing configuration, that slow down or speed up the whole animation step to compensate - for varaiation of the framerate. */ + for varaiation of the framerate. */ time_factor = (float)(system_time() - before_frame) * (1.0/4e4); } return 0; @@ -2213,16 +2215,16 @@ ChartWindow::Animation2(void *data) if (w->fKillThread) return 0; } while (status == B_TIMED_OUT || status == B_INTERRUPTED); - + /* the duration of the processing is needed to control the dynamic load split (see RefreshStar) */ bigtime_t before = system_time(); RefreshStarPacket(w->fSecondThreadBuffer, &w->fStars2, &w->fGeometry); RefreshStarPacket(w->fSecondThreadBuffer, &w->fSpecials2, &w->fGeometry); bigtime_t after = system_time(); - + w->fSecondThreadDelay = after-before; - + release_sem(w->fSecondThreadRelease); } return 0; @@ -2234,7 +2236,7 @@ ChartWindow::SetCubeOffset() { int32 i; TPoint min, max, dx, dy, dz, p1; - + /* calculate the shortest aligned cube encapsulating the pyramid of vision, by calculating the min and max on the 3 main axis of the coordinates of the 8 extremities of the pyramid of @@ -2242,11 +2244,11 @@ ChartWindow::SetCubeOffset() cut plan) */ min.x = min.y = min.z = 10.0; max.x = max.y = max.z = -10.0; - + dx = fCamera.Axis(0)*(DH_REF*0.5); dy = fCamera.Axis(1)*(DV_REF*0.5); dz = fCamera.Axis(2)*fDepthRef; - + for (i=0; i<8; i++) { /* left side / right side */ if (i&1) p1 = dz + dx; @@ -2254,19 +2256,19 @@ ChartWindow::SetCubeOffset() /* top side / bottom side */ if (i&2) p1 = p1 + dy; else p1 = p1 - dy; - /* rear cut plan / front cut plan */ + /* rear cut plan / front cut plan */ if (i&4) p1 = p1 * (1.0 / Z_CUT_RATIO); /* relative to the position of the camera */ p1 = p1 + fOrigin; - if (min.x > p1.x) min.x = p1.x; - if (min.y > p1.y) min.y = p1.y; - if (min.z > p1.z) min.z = p1.z; - if (max.x < p1.x) max.x = p1.x; - if (max.y < p1.y) max.y = p1.y; - if (max.z < p1.z) max.z = p1.z; + if (min.x > p1.x) min.x = p1.x; + if (min.y > p1.y) min.y = p1.y; + if (min.z > p1.z) min.z = p1.z; + if (max.x < p1.x) max.x = p1.x; + if (max.y < p1.y) max.y = p1.y; + if (max.z < p1.z) max.z = p1.z; } - + /* offset the camera origin by +1 or -1 on any axis (which doesn't change its relative position in the cubic torus as the cubic torus repeat itself identicaly for any move @@ -2304,7 +2306,7 @@ ChartWindow::SetCubeOffset() max.z -= 1.0; fOrigin.z -= 1.0; } - + /* set the cutting plans. For example, if the bouding box of the pyramid of vision of the camera imcludes only X in [0.43 ; 1.37], we know that points with X in [0 ; 0.4] are @@ -2328,7 +2330,7 @@ void ChartWindow::CameraAnimation(float time_factor) { TPoint move; - + switch (fCurrentSettings.animation) { /* Slow rotation around the "center" of the visible area. */ case ANIMATION_ROTATE : @@ -2336,24 +2338,24 @@ ChartWindow::CameraAnimation(float time_factor) move = fCamera.Axis(2); move = move * 0.45; fOrigin = fOrigin + move; - + /* turn around the alpha angle of the spheric rotation matrix */ fCameraAlpha += 0.011*time_factor; if (fCameraAlpha > 2*3.14159) fCameraAlpha -= 2*3.14159; - - /* set the other two angles close from hardcoded values */ + + /* set the other two angles close from hardcoded values */ if (fCameraTheta < 0.18) fCameraTheta += 0.003*time_factor; if (fCameraTheta > 0.22) fCameraTheta -= 0.003*time_factor; - + if (fCameraPhi < -0.02) fCameraPhi += 0.003*time_factor; if (fCameraPhi > 0.02) fCameraPhi -= 0.003*time_factor; - + fCamera.Set(fCameraAlpha, fCameraTheta, fCameraPhi); fCameraInvert = fCamera.Transpose(); move = fCamera.Axis(2); @@ -2363,7 +2365,7 @@ ChartWindow::CameraAnimation(float time_factor) again the parameters specific to the pyramid of vision. */ SetCubeOffset(); break; - + case ANIMATION_SLOW_MOVE : /* Just move forward, at slow speed */ move = fCamera.Axis(2); @@ -2371,7 +2373,7 @@ ChartWindow::CameraAnimation(float time_factor) fOrigin = fOrigin + move; SetCubeOffset(); break; - + case ANIMATION_FAST_MOVE : /* Just move forward, at fast speed */ move = fCamera.Axis(2); @@ -2379,7 +2381,7 @@ ChartWindow::CameraAnimation(float time_factor) fOrigin = fOrigin + move; SetCubeOffset(); break; - + case ANIMATION_FREE_MOVE : /* go into advanced selection process no more than once every 0.5 time unit (average time). */ @@ -2388,7 +2390,7 @@ ChartWindow::CameraAnimation(float time_factor) fLastDynamicDelay -= 0.5; if (fLastDynamicDelay > 0.2) fLastDynamicDelay = 0.2; - + /* if we're not following any target, then just turn randomly (modifying only the direction of the acceleration) */ @@ -2415,52 +2417,52 @@ ChartWindow::CameraAnimation(float time_factor) /* if following a target, try to turn in its direction */ else FollowTarget(); - - /* Change target everyonce in a while... */ + + /* Change target everyonce in a while... */ if ((fCrcAlea & 0xf80) == 0) SelectNewTarget(); - + /* depending the direction of acceleration, increase or reduce the angular speed of the 3 spherical angles. */ if (fCountAlpha < 0) fDynamicAlpha += -0.0005 - fDynamicAlpha * 0.025; else if (fCountAlpha > 0) fDynamicAlpha += 0.0005 - fDynamicAlpha * 0.025; - + if (fCountTheta < 0) fDynamicTheta += -0.0002 - fDynamicTheta * 0.025; else if (fCountTheta > 0) fDynamicTheta += 0.0002 - fDynamicTheta * 0.025; - + if (fCountPhi < 0) fDynamicPhi += -0.00025 - fDynamicPhi * 0.025; else if (fCountPhi >0) fDynamicPhi += 0.00025 - fDynamicPhi * 0.025; } - /* turn the camera following the specified angular speed */ + /* turn the camera following the specified angular speed */ fCameraAlpha += fDynamicAlpha*time_factor; if (fCameraAlpha < 0.0) fCameraAlpha += 2*3.14159; else if (fCameraAlpha > 2*3.14159) fCameraAlpha -= 2*3.14159; - + fCameraTheta += fDynamicTheta*time_factor; if (fCameraTheta < 0.0) fCameraTheta += 2*3.14159; else if (fCameraTheta > 2*3.14159) fCameraTheta -= 2*3.14159; - + fCameraPhi += fDynamicPhi*time_factor; if (fCameraPhi < 0.0) fCameraPhi += 2*3.14159; else if (fCameraPhi > 2*3.14159) fCameraPhi -= 2*3.14159; - - /* Set the new rotation matrix of the camera */ + + /* Set the new rotation matrix of the camera */ fCamera.Set(fCameraAlpha, fCameraTheta, fCameraPhi); fCameraInvert = fCamera.Transpose(); - + /* move the camera forward at medium speed */ move = fCamera.Axis(2); move = move * 0.0115*time_factor; @@ -2494,7 +2496,7 @@ ChartWindow::SelectNewTarget() } /* other potential targets are the key_points defined in the star field. */ - else + else pt = fKeyPoints[i]; /* Qualify the interest of the potential target in @@ -2511,12 +2513,12 @@ ChartWindow::SelectNewTarget() ftmp = 1.0/dist; pt.x *= ftmp; pt.y *= ftmp; - pt.z *= ftmp; + pt.z *= ftmp; vect = pt ^ axis; lateral = axis.Length(); axial = pt.x*axis.x + pt.y*axis.y + pt.z*axis.z; ratio = (lateral/axial) * sqrt(dist); - + /* keep track of the best possible choice */ if ((dist > 0.05) && (ratio < ratio_min)) { ratio_min = ratio; @@ -2524,7 +2526,7 @@ ChartWindow::SelectNewTarget() } } - /* record what target has been chosen */ + /* record what target has been chosen */ fTrackingTarget = index_min+2; } @@ -2568,7 +2570,7 @@ ChartWindow::FollowTarget() sphi = sin(fCameraPhi); x0 = x*cphi - y*sphi; y0 = x*sphi + y*cphi; - + /* need to move first on the left/right axis */ if (abs(x0) > abs(y0)) { if (x0 > 0) @@ -2577,7 +2579,7 @@ ChartWindow::FollowTarget() fCountAlpha = 1; fCountTheta = 0; fCountPhi = 0; - } + } /* need to move first on the top/bottom axis */ else { if (y0 > 0) @@ -2586,7 +2588,7 @@ ChartWindow::FollowTarget() fCountTheta = 1; fCountAlpha = 0; fCountPhi = 0; - } + } } } @@ -2620,7 +2622,7 @@ ChartWindow::AnimSpecials(float time_step) fSpecials.list[j].x = fComet[j].x; fSpecials.list[j].y = fComet[j].y; fSpecials.list[j].z = fComet[j].z; - + /* for other point, the ones that are ejected from the comet, depending for allow long they have been ejected... */ s = fSpecials.list+j+2; @@ -2650,11 +2652,11 @@ ChartWindow::AnimSpecials(float time_step) } } break; - + case SPECIAL_NOVAS : /* Novas are just stars (usualy invisible) that periodically become much brighter during a suddent flash, then disappear - again until their next cycle */ + again until their next cycle */ sp = fSpecialList; for (i=0; inova.count -= time_step; @@ -2671,7 +2673,7 @@ ChartWindow::AnimSpecials(float time_step) sp++; } break; - + case SPECIAL_BATTLE : /* not implemented */ break; @@ -2708,7 +2710,7 @@ ChartWindow::RefreshStars(buffer *buf, float time_step) if (fCurrentSettings.second_thread) { int32 star_threshold = (int32)((float)fStars.count * fSecondThreadThreshold + 0.5); int32 special_threshold = (int32)((float)fSpecials.count * fSecondThreadThreshold + 0.5); - + /* split the work load (star and special animation) between the two threads, proportionnaly to the last split factor determined during the last @@ -2719,54 +2721,54 @@ ChartWindow::RefreshStars(buffer *buf, float time_step) stars1.erase_count = star_threshold; if (stars1.erase_count > fStars.erase_count) stars1.erase_count = fStars.erase_count; - + fStars2.list = fStars.list + star_threshold; fStars2.count = fStars.count - star_threshold; fStars2.erase_count = fStars.erase_count - star_threshold; if (fStars2.erase_count < 0) fStars2.erase_count = 0; - + star_packet specials1; specials1.list = fSpecials.list; specials1.count = special_threshold; specials1.erase_count = special_threshold; if (specials1.erase_count > fSpecials.erase_count) specials1.erase_count = fSpecials.erase_count; - + fSpecials2.list = fSpecials.list + special_threshold; fSpecials2.count = fSpecials.count - special_threshold; fSpecials2.erase_count = fSpecials.erase_count - special_threshold; if (fSpecials2.erase_count < 0) fSpecials2.erase_count = 0; - + fSecondThreadBuffer = buf; - + /* release the slave thread */ release_sem(fSecondThreadLock); - + /* do its own part (time it) */ bigtime_t before = system_time(); RefreshStarPacket(buf, &stars1, &fGeometry); RefreshStarPacket(buf, &specials1, &fGeometry); bigtime_t after = system_time(); - - /* wait for completion of the second thread */ + + /* wait for completion of the second thread */ while (acquire_sem(fSecondThreadRelease) == B_INTERRUPTED) ; - + /* calculate the new optimal split ratio depending of the previous one and the time used by both threads to do their work. */ float ratio = ((float)fSecondThreadDelay/(float)(after-before)) * (fSecondThreadThreshold/(1.0-fSecondThreadThreshold)); fSecondThreadThreshold = ratio / (1.0+ratio); - + } else { /* In single-threaded mode, nothing fancy to be done. */ RefreshStarPacket(buf, &fStars, &fGeometry); RefreshStarPacket(buf, &fSpecials, &fGeometry); } - + /* All the stars that were drawn will have to be erased during the next frame. */ fStars.erase_count = fStars.count; @@ -2832,7 +2834,7 @@ ChartWindow::CheckBitmap(color_space depth, int32 width, int32 height) void -ChartWindow::SetBitmapClipping(int32 width, int32 height) +ChartWindow::SetBitmapClipping(int32 width, int32 height) { /* Set the bitmap buffer clipping to the required size of the buffer (even if the allocated buffer is larger) */ @@ -2855,13 +2857,13 @@ ChartWindow::SetBitmapBackGround() uint32 *bits; uint32 color; - /* set the bitmap buffer to the right background color */ + /* set the bitmap buffer to the right background color */ bits = (uint32*)fOffscreen->Bits(); count = fOffscreen->BitsLength()/4; color = fBitmapBuffer.back_color; for (i=0; ibuffer_state & B_DIRECT_MODE_MASK) { @@ -2906,7 +2908,7 @@ ChartWindow::SwitchContext(direct_buffer_info *info) description of the full content area. As we want to use only the animation view part of the window, we will need to compensate for that when update the descriptor. */ - + /* This calculate the base address of the animation view, taking into account the base address of the screen buffer, the position of the window and the position of the view in the window */ @@ -2917,7 +2919,7 @@ ChartWindow::SwitchContext(direct_buffer_info *info) fDirectBuffer.bytes_per_row = info->bytes_per_row; SetColorSpace(&fDirectBuffer, info->pixel_format); SetPatternBits(&fDirectBuffer); - + /* the width and height of the animation view are linked to the width and height of the window itself, reduced by the size of the borders reserved for the UI. */ @@ -2925,7 +2927,7 @@ ChartWindow::SwitchContext(direct_buffer_info *info) info->window_bounds.right-info->window_bounds.left+1 - LEFT_WIDTH; fDirectBuffer.buffer_height = info->window_bounds.bottom-info->window_bounds.top+1 - TOP_LEFT_LIMIT; - + /* Now, we go through the clipping list and "clip" the clipping rectangle to the animation view boundary. */ j = 0; @@ -2938,7 +2940,7 @@ ChartWindow::SwitchContext(direct_buffer_info *info) fDirectBuffer.clip_list[j].left = LEFT_WIDTH; fDirectBuffer.clip_list[j].right = info->clip_list[i].right - info->window_bounds.left; fDirectBuffer.clip_list[j].bottom = info->clip_list[i].bottom - info->window_bounds.top; - + /* All clipped rectangle that are not empty are recorded in the buffer clipping list. We keep only the 64 first (as a reasonnable approximation of most cases), but the rectangle @@ -2960,8 +2962,8 @@ ChartWindow::SwitchContext(direct_buffer_info *info) be made invisible by the extra animation view clipping */ fDirectBuffer.clip_list_count = j; - /* the bounding box of the clipping list need to be calculate again - from scratsh. Clipping the bounding box of the window clipping + /* the bounding box of the clipping list need to be calculated again + from scratch. Clipping the bounding box of the window clipping region to the animation view can give us an incorrect (larger) bounding box. Remember that the bounding box of a region is required to be minimal */ @@ -2994,7 +2996,7 @@ ChartWindow::SwitchContext(direct_buffer_info *info) need to be immediatly applied to the engine. */ SetGeometry(fDirectBuffer.buffer_width, fDirectBuffer.buffer_height); /* if the buffer was reset then - we cancel the erasing of the stars for the next frame. */ + we cancel the erasing of the stars for the next frame. */ if (info->buffer_state & B_BUFFER_RESET) { fStars.erase_count = 0; } @@ -3007,7 +3009,7 @@ ChartWindow::SwitchContext(direct_buffer_info *info) } break; - /* stop a direct screen connection */ + /* stop a direct screen connection */ case B_DIRECT_STOP : /* set the status as not connected */ fDirectConnected = false;