Core/Cells: Improve cell copy constructor and argument passing codegen (now fully done through a single register)
This commit is contained in:
1 parent
7d2e4e1993
commit
d5cb122e3a
2 files changed
+8
-31
No files matched your search
@@ -18,8 +18,6 @@
|
|||||||
#ifndef TRINITY_CELL_H
|
#ifndef TRINITY_CELL_H
|
||||||
#define TRINITY_CELL_H
|
#define TRINITY_CELL_H
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include "TypeContainer.h"
|
#include "TypeContainer.h"
|
||||||
#include "TypeContainerVisitor.h"
|
#include "TypeContainerVisitor.h"
|
||||||
|
|
||||||
@@ -47,10 +45,9 @@ struct CellArea
|
|||||||
|
|
||||||
struct Cell
|
struct Cell
|
||||||
{
|
{
|
||||||
Cell() { data.All = 0; }
|
Cell() : data() { }
|
||||||
Cell(Cell const& cell) { data.All = cell.data.All; }
|
|
||||||
explicit Cell(CellCoord const& p);
|
explicit Cell(CellCoord const& p);
|
||||||
explicit Cell(float x, float y);
|
explicit Cell(float x, float y) : Cell(Trinity::ComputeCellCoord(x, y)) { }
|
||||||
|
|
||||||
void Compute(uint32 &x, uint32 &y) const
|
void Compute(uint32 &x, uint32 &y) const
|
||||||
{
|
{
|
||||||
@@ -84,24 +81,17 @@ struct Cell
|
|||||||
data.Part.grid_y * MAX_NUMBER_OF_CELLS+data.Part.cell_y);
|
data.Part.grid_y * MAX_NUMBER_OF_CELLS+data.Part.cell_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cell& operator=(Cell const& cell)
|
|
||||||
{
|
|
||||||
this->data.All = cell.data.All;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator == (Cell const& cell) const { return (data.All == cell.data.All); }
|
bool operator == (Cell const& cell) const { return (data.All == cell.data.All); }
|
||||||
bool operator != (Cell const& cell) const { return !operator == (cell); }
|
bool operator != (Cell const& cell) const { return !operator == (cell); }
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
unsigned grid_x : 8;
|
uint8 grid_x;
|
||||||
unsigned grid_y : 8;
|
uint8 grid_y;
|
||||||
unsigned cell_x : 8;
|
uint8 cell_x;
|
||||||
unsigned cell_y : 8;
|
uint8 cell_y;
|
||||||
unsigned nocreate : 8;
|
uint8 nocreate;
|
||||||
unsigned reserved : 24;
|
|
||||||
} Part;
|
} Part;
|
||||||
uint64 All;
|
uint64 All;
|
||||||
} data;
|
} data;
|
||||||
|
|||||||
@@ -24,25 +24,12 @@
|
|||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
|
|
||||||
inline Cell::Cell(CellCoord const& p)
|
inline Cell::Cell(CellCoord const& p) : data()
|
||||||
{
|
{
|
||||||
data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS;
|
data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS;
|
||||||
data.Part.grid_y = p.y_coord / MAX_NUMBER_OF_CELLS;
|
data.Part.grid_y = p.y_coord / MAX_NUMBER_OF_CELLS;
|
||||||
data.Part.cell_x = p.x_coord % MAX_NUMBER_OF_CELLS;
|
data.Part.cell_x = p.x_coord % MAX_NUMBER_OF_CELLS;
|
||||||
data.Part.cell_y = p.y_coord % MAX_NUMBER_OF_CELLS;
|
data.Part.cell_y = p.y_coord % MAX_NUMBER_OF_CELLS;
|
||||||
data.Part.nocreate = 0;
|
|
||||||
data.Part.reserved = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Cell::Cell(float x, float y)
|
|
||||||
{
|
|
||||||
CellCoord p = Trinity::ComputeCellCoord(x, y);
|
|
||||||
data.Part.grid_x = p.x_coord / MAX_NUMBER_OF_CELLS;
|
|
||||||
data.Part.grid_y = p.y_coord / MAX_NUMBER_OF_CELLS;
|
|
||||||
data.Part.cell_x = p.x_coord % MAX_NUMBER_OF_CELLS;
|
|
||||||
data.Part.cell_y = p.y_coord % MAX_NUMBER_OF_CELLS;
|
|
||||||
data.Part.nocreate = 0;
|
|
||||||
data.Part.reserved = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline CellArea Cell::CalculateCellArea(float x, float y, float radius)
|
inline CellArea Cell::CalculateCellArea(float x, float y, float radius)
|
||||||
|
|||||||
Reference in new issue
Block a user