--Bug fixes

-Add missing Mac build files.
 -Convert PaletteList into a Singleton<T>.
This commit is contained in:
Person
2017-02-26 09:34:43 -08:00
parent 00189531fc
commit 29c084a058
25 changed files with 178 additions and 97 deletions

View File

@ -56,8 +56,6 @@ uint Timing::m_ProcessorCount;
template class Post##varName##Variation<T>;
#define EXPORT_SINGLE_TYPE_EMBER(T) \
template<> const char* PaletteList<T>::m_DefaultFilename = "flam3-palettes.xml"; \
template<> map<string, vector<Palette<T>>> PaletteList<T>::s_Palettes = map<string, vector<Palette<T>>>(); \
template<> bool XmlToEmber<T>::m_Init = false; \
template<> vector<string> XmlToEmber<T>::m_FlattenNames = vector<string>(); \
template<> unordered_map<string, string> XmlToEmber<T>::m_BadParamNames = unordered_map<string, string>(); \

View File

@ -9,7 +9,6 @@ namespace EmberNs
template <typename T>
PaletteList<T>::PaletteList()
{
//Add(string(m_DefaultFilename));
}
/// <summary>

View File

@ -20,14 +20,11 @@ namespace EmberNs
/// Template argument should always be float (which makes the templating of this class pointless).
/// </summary>
template <typename T>
class EMBER_API PaletteList : public EmberReport
class EMBER_API PaletteList : public EmberReport, public Singleton<PaletteList<T>>
{
public:
static const char* m_DefaultFilename;
const char* m_DefaultFilename = "flam3-palettes.xml";
PaletteList();
PaletteList(const PaletteList<T>& paletteList) = delete;
~PaletteList();
bool AddPaletteFile(const string& filename, const vector<Palette<T>>& palettes);
bool AddEmptyPaletteFile(const string& filename);
bool AddPaletteToFile(const string& filename, const Palette<T>& palette);
@ -52,11 +49,12 @@ public:
bool IsModifiable(const string& filename);
const map<string, vector<Palette<T>>>& Palettes() const;
SINGLETON_DERIVED_DECL(PaletteList<T>);
private:
PaletteList();
bool Save(const string& filename);
void ParsePalettes(xmlNode* node, const shared_ptr<string>& filename, vector<Palette<T>>& palettes);
bool ParsePalettes(const string& buf, const shared_ptr<string>& filename, vector<Palette<T>>& palettes);
static map<string, vector<Palette<T>>> s_Palettes;//The map of filenames to vectors that store the palettes.
map<string, vector<Palette<T>>> s_Palettes;//The map of filenames to vectors that store the palettes.
};
}

View File

@ -62,10 +62,11 @@ public:
/// <param name="palettePath">The full path and filename of the palette file</param>
/// <param name="renderer">A pre-constructed renderer to use. The caller should not delete this.</param>
SheepTools(const string& palettePath, Renderer<T, bucketT>* renderer)
: m_VariationList(VariationList<T>::Instance())
: m_VariationList(VariationList<T>::Instance()),
m_PaletteList(PaletteList<float>::Instance())
{
Timing t;
m_PaletteList.Add(palettePath);
m_PaletteList->Add(palettePath);
m_Renderer = unique_ptr<Renderer<T, bucketT>>(renderer);
m_Rand = QTIsaac<ISAAC_SIZE, ISAAC_INT>(ISAAC_INT(t.Tic()), ISAAC_INT(t.Tic() * 2), ISAAC_INT(t.Tic() * 3));
}
@ -90,8 +91,8 @@ public:
ember.AddXform(xform2);
ember.AddXform(xform3);
if (m_PaletteList.Size())
ember.m_Palette = *m_PaletteList.GetRandomPalette();
if (m_PaletteList->Size())
ember.m_Palette = *m_PaletteList->GetRandomPalette();
return ember;
}
@ -365,8 +366,8 @@ public:
}
else//Randomize palette only.
{
if (m_PaletteList.Size())
ember.m_Palette = *m_PaletteList.GetRandomPalette();
if (m_PaletteList->Size())
ember.m_Palette = *m_PaletteList->GetRandomPalette();
//If the palette retrieval fails, skip the mutation.
if (ember.m_Palette.m_Index >= 0)
@ -607,8 +608,8 @@ public:
};
ember.Clear();
if (m_PaletteList.Size())
ember.m_Palette = *m_PaletteList.GetRandomPalette();
if (m_PaletteList->Size())
ember.m_Palette = *m_PaletteList->GetRandomPalette();
ember.m_Time = 0;
ember.m_Interp = eInterp::EMBER_INTERP_LINEAR;
@ -883,9 +884,9 @@ public:
{
if (changePalette)
{
if (m_PaletteList.Size())
if (m_PaletteList->Size())
{
ember.m_Palette = *m_PaletteList.GetRandomPalette();
ember.m_Palette = *m_PaletteList->GetRandomPalette();
}
else
{
@ -1365,7 +1366,7 @@ private:
unique_ptr<XaosIterator<T>> m_XaosIterator = make_unique<XaosIterator<T>>();
unique_ptr<Renderer<T, bucketT>> m_Renderer;
QTIsaac<ISAAC_SIZE, ISAAC_INT> m_Rand;
PaletteList<float> m_PaletteList;
shared_ptr<PaletteList<float>> m_PaletteList;
shared_ptr<VariationList<T>> m_VariationList;
};
}

View File

@ -37,7 +37,8 @@ Locale::~Locale()
/// </summary>
template <typename T>
XmlToEmber<T>::XmlToEmber()
: m_VariationList(VariationList<T>::Instance())
: m_VariationList(VariationList<T>::Instance()),
m_PaletteList(PaletteList<float>::Instance())
{
Timing t;
@ -388,7 +389,7 @@ bool XmlToEmber<T>::Parse(const char* filename, C<Ember<T>, Alloc>& embers, bool
string buf;
//Ensure palette list is setup first.
if (!m_PaletteList.Size())
if (!m_PaletteList->Size())
{
AddToReport(string(loc) + " : Palette list must be initialized before parsing embers.");
return false;
@ -468,7 +469,7 @@ void XmlToEmber<T>::ScanForEmberNodes(xmlNode* curNode, char* parentFile, C<Embe
if (currentEmber.PaletteIndex() != -1)
{
if (auto pal = m_PaletteList.GetPaletteByFilename(PaletteList<T>::m_DefaultFilename, currentEmber.PaletteIndex()))
if (auto pal = m_PaletteList->GetPaletteByFilename(m_PaletteList->m_DefaultFilename, currentEmber.PaletteIndex()))
currentEmber.m_Palette = *pal;
else
AddToReport(string(loc) + " : Error assigning palette with index " + std::to_string(currentEmber.PaletteIndex()));

View File

@ -71,6 +71,6 @@ private:
static unordered_map<string, string> m_BadParamNames;
static vector<pair<pair<string, string>, vector<string>>> m_BadVariationNames;
shared_ptr<VariationList<T>> m_VariationList;//The variation list used to make copies of variations to populate the embers with.
PaletteList<T> m_PaletteList;
shared_ptr<PaletteList<float>> m_PaletteList;
};
}