Decoration: Handle facedir and wallmounted param2types with schematic rotation
parent
c813a3cc53
commit
ce955f37ba
|
@ -237,6 +237,8 @@ Decoration::~Decoration() {
|
||||||
|
|
||||||
|
|
||||||
void Decoration::resolveNodeNames(INodeDefManager *ndef) {
|
void Decoration::resolveNodeNames(INodeDefManager *ndef) {
|
||||||
|
this->ndef = ndef;
|
||||||
|
|
||||||
if (c_place_on == CONTENT_IGNORE)
|
if (c_place_on == CONTENT_IGNORE)
|
||||||
c_place_on = ndef->getId(place_on_name);
|
c_place_on = ndef->getId(place_on_name);
|
||||||
}
|
}
|
||||||
|
@ -553,7 +555,7 @@ std::string DecoSchematic::getName() {
|
||||||
|
|
||||||
|
|
||||||
void DecoSchematic::blitToVManip(v3s16 p, ManualMapVoxelManipulator *vm,
|
void DecoSchematic::blitToVManip(v3s16 p, ManualMapVoxelManipulator *vm,
|
||||||
int rot, bool force_placement) {
|
Rotation rot, bool force_placement) {
|
||||||
int xstride = 1;
|
int xstride = 1;
|
||||||
int ystride = size.X;
|
int ystride = size.X;
|
||||||
int zstride = size.X * size.Y;
|
int zstride = size.X * size.Y;
|
||||||
|
@ -594,7 +596,7 @@ void DecoSchematic::blitToVManip(v3s16 p, ManualMapVoxelManipulator *vm,
|
||||||
u32 vi = vm->m_area.index(p.X + x, p.Y + y, p.Z + z);
|
u32 vi = vm->m_area.index(p.X + x, p.Y + y, p.Z + z);
|
||||||
if (!vm->m_area.contains(vi))
|
if (!vm->m_area.contains(vi))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (schematic[i].getContent() == CONTENT_IGNORE)
|
if (schematic[i].getContent() == CONTENT_IGNORE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -609,6 +611,9 @@ void DecoSchematic::blitToVManip(v3s16 p, ManualMapVoxelManipulator *vm,
|
||||||
|
|
||||||
vm->m_data[vi] = schematic[i];
|
vm->m_data[vi] = schematic[i];
|
||||||
vm->m_data[vi].param1 = 0;
|
vm->m_data[vi].param1 = 0;
|
||||||
|
|
||||||
|
if (rot)
|
||||||
|
vm->m_data[vi].rotateAlongYAxis(ndef, rot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
src/mapgen.h
14
src/mapgen.h
|
@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "irrlichttypes_extrabloated.h"
|
#include "irrlichttypes_extrabloated.h"
|
||||||
#include "util/container.h" // UniqueQueue
|
#include "util/container.h" // UniqueQueue
|
||||||
#include "gamedef.h"
|
#include "gamedef.h"
|
||||||
|
#include "nodedef.h"
|
||||||
#include "mapnode.h"
|
#include "mapnode.h"
|
||||||
#include "noise.h"
|
#include "noise.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
@ -63,7 +64,6 @@ class EmergeManager;
|
||||||
class MapBlock;
|
class MapBlock;
|
||||||
class ManualMapVoxelManipulator;
|
class ManualMapVoxelManipulator;
|
||||||
class VoxelManipulator;
|
class VoxelManipulator;
|
||||||
class INodeDefManager;
|
|
||||||
struct BlockMakeData;
|
struct BlockMakeData;
|
||||||
class VoxelArea;
|
class VoxelArea;
|
||||||
class Map;
|
class Map;
|
||||||
|
@ -216,6 +216,8 @@ struct CutoffData {
|
||||||
|
|
||||||
class Decoration {
|
class Decoration {
|
||||||
public:
|
public:
|
||||||
|
INodeDefManager *ndef;
|
||||||
|
|
||||||
int mapseed;
|
int mapseed;
|
||||||
std::string place_on_name;
|
std::string place_on_name;
|
||||||
content_t c_place_on;
|
content_t c_place_on;
|
||||||
|
@ -262,14 +264,6 @@ public:
|
||||||
|
|
||||||
#define MTSCHEM_FILE_SIGNATURE 0x4d54534d // 'MTSM'
|
#define MTSCHEM_FILE_SIGNATURE 0x4d54534d // 'MTSM'
|
||||||
|
|
||||||
enum Rotation {
|
|
||||||
ROTATE_0,
|
|
||||||
ROTATE_90,
|
|
||||||
ROTATE_180,
|
|
||||||
ROTATE_270,
|
|
||||||
ROTATE_RAND,
|
|
||||||
};
|
|
||||||
|
|
||||||
class DecoSchematic : public Decoration {
|
class DecoSchematic : public Decoration {
|
||||||
public:
|
public:
|
||||||
std::string filename;
|
std::string filename;
|
||||||
|
@ -291,7 +285,7 @@ public:
|
||||||
virtual std::string getName();
|
virtual std::string getName();
|
||||||
|
|
||||||
void blitToVManip(v3s16 p, ManualMapVoxelManipulator *vm,
|
void blitToVManip(v3s16 p, ManualMapVoxelManipulator *vm,
|
||||||
int rot, bool force_placement);
|
Rotation rot, bool force_placement);
|
||||||
|
|
||||||
bool loadSchematicFile();
|
bool loadSchematicFile();
|
||||||
void saveSchematicFile(INodeDefManager *ndef);
|
void saveSchematicFile(INodeDefManager *ndef);
|
||||||
|
|
|
@ -28,6 +28,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
static const Rotation wallmounted_to_rot[] = {
|
||||||
|
ROTATE_0, ROTATE_180, ROTATE_90, ROTATE_270
|
||||||
|
};
|
||||||
|
static const u8 rot_to_wallmounted[] = {
|
||||||
|
2, 4, 3, 5
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
MapNode
|
MapNode
|
||||||
*/
|
*/
|
||||||
|
@ -132,6 +140,24 @@ v3s16 MapNode::getWallMountedDir(INodeDefManager *nodemgr) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapNode::rotateAlongYAxis(INodeDefManager *nodemgr, Rotation rot) {
|
||||||
|
ContentParamType2 cpt2 = nodemgr->get(*this).param_type_2;
|
||||||
|
|
||||||
|
if (cpt2 == CPT2_FACEDIR) {
|
||||||
|
u8 newrot = param2 & 3;
|
||||||
|
param2 &= ~3;
|
||||||
|
param2 |= (newrot + rot) & 3;
|
||||||
|
} else if (cpt2 == CPT2_WALLMOUNTED) {
|
||||||
|
u8 wmountface = (param2 & 7);
|
||||||
|
if (wmountface <= 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Rotation oldrot = wallmounted_to_rot[wmountface - 2];
|
||||||
|
param2 &= ~7;
|
||||||
|
param2 |= rot_to_wallmounted[(oldrot + rot) & 3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static std::vector<aabb3f> transformNodeBox(const MapNode &n,
|
static std::vector<aabb3f> transformNodeBox(const MapNode &n,
|
||||||
const NodeBox &nodebox, INodeDefManager *nodemgr)
|
const NodeBox &nodebox, INodeDefManager *nodemgr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,6 +61,17 @@ enum LightBank
|
||||||
LIGHTBANK_NIGHT
|
LIGHTBANK_NIGHT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Simple rotation enum.
|
||||||
|
*/
|
||||||
|
enum Rotation {
|
||||||
|
ROTATE_0,
|
||||||
|
ROTATE_90,
|
||||||
|
ROTATE_180,
|
||||||
|
ROTATE_270,
|
||||||
|
ROTATE_RAND,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Masks for MapNode.param2 of flowing liquids
|
Masks for MapNode.param2 of flowing liquids
|
||||||
*/
|
*/
|
||||||
|
@ -181,6 +192,8 @@ struct MapNode
|
||||||
u8 getFaceDir(INodeDefManager *nodemgr) const;
|
u8 getFaceDir(INodeDefManager *nodemgr) const;
|
||||||
u8 getWallMounted(INodeDefManager *nodemgr) const;
|
u8 getWallMounted(INodeDefManager *nodemgr) const;
|
||||||
v3s16 getWallMountedDir(INodeDefManager *nodemgr) const;
|
v3s16 getWallMountedDir(INodeDefManager *nodemgr) const;
|
||||||
|
|
||||||
|
void rotateAlongYAxis(INodeDefManager *nodemgr, Rotation rot);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Gets list of node boxes (used for rendering (NDT_NODEBOX)
|
Gets list of node boxes (used for rendering (NDT_NODEBOX)
|
||||||
|
|
Loading…
Reference in New Issue