<commit_before>// For conditions of distribution and use, see copyright notice in license.txt

#include "StableHeaders.h"
#include "EC_Terrain.h"

#include "Renderer.h"
#include "IModule.h"
#include "ServiceManager.h"

#include <Ogre.h>
#include "OgreMaterialUtils.h"
#include "OgreConversionUtils.h"

#include <utility>

using namespace std;
using namespace OgreRenderer;

namespace OgreRenderer
{
typedef boost::shared_ptr<Renderer> RendererPtr;
}

namespace Environment
{

EC_Terrain::EC_Terrain(IModule* module) :
    IComponent(module->GetFramework()),
    nodeTransformation(this, "Transform"),
    xPatches(this, "Grid Width"),
    yPatches(this, "Grid Height"),
    material(this, "Material"),
    texture0(this, "Texture 0"),
    texture1(this, "Texture 1"),
    texture2(this, "Texture 2"),
    texture3(this, "Texture 3"),
    texture4(this, "Texture 4"),
    patchWidth(1),
    patchHeight(1),
    rootNode(0)
{
    QObject::connect(this, SIGNAL(ParentEntitySet()), this, SLOT(UpdateSignals()));

    xPatches.Set(1, AttributeChange::LocalOnly);
    yPatches.Set(1, AttributeChange::LocalOnly);
    patches.resize(1);
}

EC_Terrain::~EC_Terrain()
{
    Destroy();
}

void EC_Terrain::UpdateSignals()
{
    disconnect(this, SLOT(AttributeUpdated(IAttribute *)));

    connect(this, SIGNAL(OnAttributeChanged(IAttribute*, AttributeChange::Type)),
            this, SLOT(AttributeUpdated(IAttribute*)));

    connect(this, SIGNAL(TerrainSizeChanged(int)), this, SLOT(OnTerrainSizeChanged()));
    connect(this, SIGNAL(MaterialChanged(QString)), this, SLOT(OnMaterialChanged()));
    connect(this, SIGNAL(TextureChanged(QString)), this, SLOT(OnTextureChanged()));
}

void EC_Terrain::OnTerrainSizeChanged()
{
    ResizeTerrain(xPatches.Get(), yPatches.Get());
}

void EC_Terrain::OnMaterialChanged()
{
    for(int y = 0; y < patchHeight; ++y)
        for(int x = 0; x < patchWidth; ++x)
            UpdateTerrainPatchMaterial(x, y);
}
<commit_msg>Allow instantiating multiple terrain planes simultaneously.<commit_after>// For conditions of distribution and use, see copyright notice in license.txt

#include "StableHeaders.h"
#include "EC_Terrain.h"

#include "Renderer.h"
#include "IModule.h"
#include "ServiceManager.h"

#include <Ogre.h>
#include "OgreMaterialUtils.h"
#include "OgreConversionUtils.h"

#include <utility>

using namespace std;
using namespace OgreRenderer;

namespace OgreRenderer
{
typedef boost::shared_ptr<Renderer> RendererPtr;
}

namespace Environment
{

EC_Terrain::EC_Terrain(IModule* module) :
    IComponent(module->GetFramework()),
    nodeTransformation(this, "Transform"),
    xPatches(this, "Grid Width"),
    yPatches(this, "Grid Height"),
    material(this, "Material"),
    texture0(this, "Texture 0"),
    texture1(this, "Texture 1"),
    texture2(this, "Texture 2"),
    texture3(this, "Texture 3"),
    texture4(this, "Texture 4"),
    patchWidth(1),
    patchHeight(1),
    rootNode(0)
{
    QObject::connect(this, SIGNAL(ParentEntitySet()), this, SLOT(UpdateSignals()));

    xPatches.Set(1, AttributeChange::LocalOnly);
    yPatches.Set(1, AttributeChange::LocalOnly);
    patches.resize(1);
    MakePatchFlat(0, 0, 0.f);
}

EC_Terrain::~EC_Terrain()
{
    Destroy();
}

void EC_Terrain::UpdateSignals()
{
    disconnect(this, SLOT(AttributeUpdated(IAttribute *)));

    connect(this, SIGNAL(OnAttributeChanged(IAttribute*, AttributeChange::Type)),
            this, SLOT(AttributeUpdated(IAttribute*)));

    connect(this, SIGNAL(TerrainSizeChanged(int)), this, SLOT(OnTerrainSizeChanged()));
    connect(this, SIGNAL(MaterialChanged(QString)), this, SLOT(OnMaterialChanged()));
    connect(this, SIGNAL(TextureChanged(QString)), this, SLOT(OnTextureChanged()));
}

void EC_Terrain::OnTerrainSizeChanged()
{
    ResizeTerrain(xPatches.Get(), yPatches.Get());
}

void EC_Terrain::OnMaterialChanged()
{
    for(int y = 0; y < patchHeight; ++y)
        for(int x = 0; x < patchWidth; ++x)
            UpdateTerrainPatchMaterial(x, y);
}

{'fraction_non_alphanumeric': 0.14776718514801807, 'fraction_numerical': 0.009784244856999498, 'mean_word_length': 5.298578199052133, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7464261', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1309, 'n_words': 260}