1
0
Fork 0

cPrefab can draw itself into a cChunkDesc.

This commit is contained in:
madmaxoft 2014-03-27 23:03:57 +01:00
parent bbebb3a2cd
commit 7b585290fc
2 changed files with 9 additions and 6 deletions

View File

@ -9,6 +9,7 @@ uses a prefabricate in a cBlockArea for drawing itself.
#include "Globals.h" #include "Globals.h"
#include "Prefab.h" #include "Prefab.h"
#include "../WorldStorage/SchematicFileSerializer.h" #include "../WorldStorage/SchematicFileSerializer.h"
#include "ChunkDesc.h"
@ -16,7 +17,7 @@ uses a prefabricate in a cBlockArea for drawing itself.
cPrefab::cPrefab(const cPrefab::sDef & a_Def) : cPrefab::cPrefab(const cPrefab::sDef & a_Def) :
m_Size(a_Def.m_SizeX, a_Def.m_SizeY, a_Def.m_SizeZ), m_Size(a_Def.m_SizeX, a_Def.m_SizeY, a_Def.m_SizeZ),
m_HitBox(0, 0, 0, a_Def.m_SizeX, a_Def.m_SizeY, a_Def.m_SizeZ), m_HitBox(0, 0, 0, a_Def.m_SizeX - 1, a_Def.m_SizeY - 1, a_Def.m_SizeZ - 1),
m_AllowedRotations(a_Def.m_AllowedRotations), m_AllowedRotations(a_Def.m_AllowedRotations),
m_MergeStrategy(a_Def.m_MergeStrategy) m_MergeStrategy(a_Def.m_MergeStrategy)
{ {
@ -31,11 +32,13 @@ cPrefab::cPrefab(const cPrefab::sDef & a_Def) :
void cPrefab::Draw(cBlockArea & a_Dest, const cPlacedPiece * a_Placement) void cPrefab::Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const
{ {
Vector3i Placement = a_Placement->GetCoords(); Vector3i Placement = a_Placement->GetCoords();
Placement.Move(a_Dest.GetOrigin() * (-1)); int ChunkStartX = a_Dest.GetChunkX() * cChunkDef::Width;
a_Dest.Merge(m_BlockArea, Placement, m_MergeStrategy); int ChunkStartZ = a_Dest.GetChunkZ() * cChunkDef::Width;
Placement.Move(-ChunkStartX, 0, -ChunkStartZ);
a_Dest.WriteBlockArea(m_BlockArea, Placement.x, Placement.y, Placement.z, m_MergeStrategy);
} }

View File

@ -40,8 +40,8 @@ public:
cPrefab(const sDef & a_Def); cPrefab(const sDef & a_Def);
/** Draws the prefab into the specified block area, according to the placement stored in the PlacedPiece. */ /** Draws the prefab into the specified chunk, according to the placement stored in the PlacedPiece. */
void Draw(cBlockArea & a_Dest, const cPlacedPiece * a_Placement); void Draw(cChunkDesc & a_Dest, const cPlacedPiece * a_Placement) const;
/** Returns true if the prefab has any connector of the specified type. */ /** Returns true if the prefab has any connector of the specified type. */
bool HasConnectorType(int a_ConnectorType) const; bool HasConnectorType(int a_ConnectorType) const;