Merge remote-tracking branch 'refs/remotes/origin/master' into culling

This commit is contained in:
Lynix
2016-11-23 14:07:52 +01:00
100 changed files with 2585 additions and 1294 deletions

View File

@@ -87,7 +87,7 @@ namespace Nz
struct SpriteChain_XYZ_Color_UV
{
const VertexStruct_XYZ_Color_UV* vertices;
unsigned int spriteCount;
std::size_t spriteCount;
};
struct BatchedSpriteEntry
@@ -160,7 +160,7 @@ namespace Nz
const Material* material;
};
typedef std::vector<unsigned int> TransparentModelContainer;
typedef std::vector<std::size_t> TransparentModelContainer;
struct Layer
{

View File

@@ -36,10 +36,10 @@ namespace Nz
~ParticleDeclaration();
void DisableComponent(ParticleComponent component);
void EnableComponent(ParticleComponent component, ComponentType type, unsigned int offset);
void EnableComponent(ParticleComponent component, ComponentType type, std::size_t offset);
void GetComponent(ParticleComponent component, bool* enabled, ComponentType* type, unsigned int* offset) const;
unsigned int GetStride() const;
void GetComponent(ParticleComponent component, bool* enabled, ComponentType* type, std::size_t* offset) const;
std::size_t GetStride() const;
void SetStride(unsigned int stride);
@@ -60,7 +60,7 @@ namespace Nz
{
ComponentType type;
bool enabled = false;
unsigned int offset;
std::size_t offset;
/*
** -Lynix:
@@ -71,7 +71,7 @@ namespace Nz
};
std::array<Component, ParticleComponent_Max + 1> m_components;
unsigned int m_stride;
std::size_t m_stride;
static std::array<ParticleDeclaration, ParticleLayout_Max + 1> s_declarations;
static ParticleDeclarationLibrary::LibraryMap s_library;

View File

@@ -28,12 +28,12 @@ namespace Nz
void EnableLagCompensation(bool enable);
unsigned int GetEmissionCount() const;
std::size_t GetEmissionCount() const;
float GetEmissionRate() const;
bool IsLagCompensationEnabled() const;
void SetEmissionCount(unsigned int count);
void SetEmissionCount(std::size_t count);
void SetEmissionRate(float rate);
ParticleEmitter& operator=(const ParticleEmitter& emitter) = default;
@@ -49,7 +49,7 @@ namespace Nz
bool m_lagCompensationEnabled;
mutable float m_emissionAccumulator;
float m_emissionRate;
unsigned int m_emissionCount;
std::size_t m_emissionCount;
};
}

View File

@@ -45,11 +45,11 @@ namespace Nz
void* GenerateParticles(unsigned int count);
const ParticleDeclarationConstRef& GetDeclaration() const;
unsigned int GetMaxParticleCount() const;
unsigned int GetParticleCount() const;
unsigned int GetParticleSize() const;
std::size_t GetMaxParticleCount() const;
std::size_t GetParticleCount() const;
std::size_t GetParticleSize() const;
void KillParticle(unsigned int index);
void KillParticle(std::size_t index);
void KillParticles();
void RemoveController(ParticleController* controller);
@@ -81,6 +81,9 @@ namespace Nz
};
std::set<unsigned int, std::greater<unsigned int>> m_dyingParticles;
std::size_t m_maxParticleCount;
std::size_t m_particleCount;
std::size_t m_particleSize;
mutable std::vector<UInt8> m_buffer;
std::vector<ParticleControllerRef> m_controllers;
std::vector<EmitterEntry> m_emitters;
@@ -88,9 +91,6 @@ namespace Nz
ParticleDeclarationConstRef m_declaration;
ParticleRendererRef m_renderer;
bool m_processing;
unsigned int m_maxParticleCount;
unsigned int m_particleCount;
unsigned int m_particleSize;
};
}

View File

@@ -23,7 +23,7 @@ namespace Nz
// Then the component that are interesting
bool enabled;
ComponentType type;
unsigned int offset;
std::size_t offset;
m_declaration->GetComponent(component, &enabled, &type, &offset);
if (enabled)
@@ -54,7 +54,7 @@ namespace Nz
// Then the component that are interesting
bool enabled;
ComponentType type;
unsigned int offset;
std::size_t offset;
m_declaration->GetComponent(component, &enabled, &type, &offset);
if (enabled)

View File

@@ -29,7 +29,7 @@ namespace Nz
static AbstractRenderTechnique* GetByName(const String& name, int* techniqueRanking = nullptr);
static AbstractRenderTechnique* GetByRanking(int maxRanking, int* techniqueRanking = nullptr);
static unsigned int GetCount();
static std::size_t GetCount();
static void Register(const String& name, int ranking, RenderTechniqueFactory factory);

View File

@@ -47,9 +47,11 @@ namespace Nz
inline void SetCornerColor(RectCorner corner, const Color& color);
inline void SetDefaultMaterial();
inline void SetMaterial(MaterialRef material, bool resizeSprite = true);
bool SetMaterial(String materialName, bool resizeSprite = true);
inline void SetOrigin(const Vector3f& origin);
inline void SetSize(const Vector2f& size);
inline void SetSize(float sizeX, float sizeY);
bool SetTexture(String textureName, bool resizeSprite = true);
inline void SetTexture(TextureRef texture, bool resizeSprite = true);
inline void SetTextureCoords(const Rectf& coords);
inline void SetTextureRect(const Rectui& rect);

View File

@@ -184,12 +184,11 @@ namespace Nz
}
/*!
* \brief Sets the material of the sprite
* \brief Changes the material of the sprite
*
* \param material Material for the sprite
* \param resizeSprite Should sprite be resized to the material size (diffuse map)
* \param resizeSprite Should the sprite be resized to the texture size?
*/
inline void Sprite::SetMaterial(MaterialRef material, bool resizeSprite)
{
m_material = std::move(material);
@@ -249,16 +248,19 @@ namespace Nz
/*!
* \brief Sets the texture of the sprite
*
* Assign a texture to the sprite material
*
* \param texture Texture for the sprite
* \param resizeSprite Should sprite be resized to the texture size
* \param resizeSprite Should the sprite be resized to the texture size?
*
* \remark The sprite material gets copied to prevent accidentally changing other drawable materials
*/
inline void Sprite::SetTexture(TextureRef texture, bool resizeSprite)
{
if (!m_material)
SetDefaultMaterial();
else if (m_material->GetReferenceCount() > 1)
m_material = Material::New(*m_material); // Copie
m_material = Material::New(*m_material); // Copy the material
if (resizeSprite && texture && texture->IsValid())
SetSize(Vector2f(Vector2ui(texture->GetSize())));