mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
6c3e5642f8
# Conflicts: # cmake/CompileFlags.cmake # src/crashlog.cpp # src/fileio.cpp # src/fileio_func.h # src/fios_gui.cpp # src/ini_load.cpp # src/ini_type.h # src/lang/english.txt # src/lang/german.txt # src/lang/korean.txt # src/network/network_client.cpp # src/order_base.h # src/order_cmd.cpp # src/os/windows/win32.cpp # src/road_cmd.cpp # src/saveload/saveload.cpp # src/saveload/saveload.h # src/settings.cpp # src/station_cmd.cpp # src/stdafx.h # src/table/settings.ini # src/tree_cmd.cpp # src/tree_gui.cpp # src/vehicle_base.h # src/video/cocoa/cocoa_v.mm # src/video/cocoa/event.mm # src/video/cocoa/wnd_quartz.mm # src/viewport.cpp # src/widgets/tree_widget.h
68 lines
3.1 KiB
C++
68 lines
3.1 KiB
C++
/*
|
|
* This file is part of OpenTTD.
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
/** @file viewport_sprite_sorter.h Types related to sprite sorting. */
|
|
|
|
#include "stdafx.h"
|
|
#include "core/smallvec_type.hpp"
|
|
#include "core/bitmath_func.hpp"
|
|
#include "gfx_type.h"
|
|
|
|
#ifndef VIEWPORT_SPRITE_SORTER_H
|
|
#define VIEWPORT_SPRITE_SORTER_H
|
|
|
|
/** Parent sprite that should be drawn */
|
|
#ifdef _MSC_VER
|
|
struct __declspec(align(16)) ParentSpriteToDraw {
|
|
#else
|
|
struct __attribute__ ((aligned (16))) ParentSpriteToDraw {
|
|
#endif
|
|
/* Block of 16B loadable in xmm register */
|
|
int32 xmin; ///< minimal world X coordinate of bounding box
|
|
int32 ymin; ///< minimal world Y coordinate of bounding box
|
|
int32 zmin; ///< minimal world Z coordinate of bounding box
|
|
int32 x; ///< screen X coordinate of sprite
|
|
|
|
/* Second block of 16B loadable in xmm register */
|
|
int32 xmax; ///< maximal world X coordinate of bounding box
|
|
int32 ymax; ///< maximal world Y coordinate of bounding box
|
|
int32 zmax; ///< maximal world Z coordinate of bounding box
|
|
int32 y; ///< screen Y coordinate of sprite
|
|
|
|
SpriteID image; ///< sprite to draw
|
|
PaletteID pal; ///< palette to use
|
|
const SubSprite *sub; ///< only draw a rectangular part of the sprite
|
|
|
|
int32 left; ///< minimal screen X coordinate of sprite (= x + sprite->x_offs), reference point for child sprites
|
|
int32 top; ///< minimal screen Y coordinate of sprite (= y + sprite->y_offs), reference point for child sprites
|
|
|
|
int32 first_child; ///< the first child to draw.
|
|
uint16 width; ///< sprite width
|
|
uint16 height; ///< sprite height, bit 15: comparison_done: used during sprite sorting: true if sprite has been compared with all other sprites
|
|
|
|
bool IsComparisonDone() const { return HasBit(this->height, 15); }
|
|
void SetComparisonDone(bool done) { SB(this->height, 15, 1, done ? 1 : 0); }
|
|
};
|
|
static_assert((sizeof(ParentSpriteToDraw) % 16) == 0);
|
|
static_assert(sizeof(ParentSpriteToDraw) <= 64);
|
|
|
|
typedef std::vector<ParentSpriteToDraw*> ParentSpriteToSortVector;
|
|
|
|
/** Type for method for checking whether a viewport sprite sorter exists. */
|
|
typedef bool (*VpSorterChecker)();
|
|
/** Type for the actual viewport sprite sorter. */
|
|
typedef void (*VpSpriteSorter)(ParentSpriteToSortVector *psd);
|
|
|
|
#ifdef WITH_SSE
|
|
bool ViewportSortParentSpritesSSE41Checker();
|
|
void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv);
|
|
#endif
|
|
|
|
void InitializeSpriteSorter();
|
|
|
|
#endif /* VIEWPORT_SPRITE_SORTER_H */
|