Permalink
Browse files

- Added config property DoNotCache to orxFX

 -> If set to true, any instance of this FX will always be entirely recreated from config, which allows for variations and random values
  • Loading branch information...
iarwain committed Jun 9, 2017
1 parent 9d6bedc commit 08093f1573c4749821f5a0e69f89ab3e043aab13
Showing with 32 additions and 25 deletions.
  1. +2 −1 code/bin/CreationTemplate.ini
  2. +28 −23 code/src/object/orxFX.c
  3. +2 −1 tutorial/bin/CreationTemplate.ini
@@ -397,7 +397,8 @@ KeepInCache = [Bool]; NB: If true, the sound data (ie. the sample itself) will a
[FXTemplate]
SlotList = FXSlotTemplate1 # FXSlotTemplate2 # ...; NB: There is a maximum of 8 slots;
Loop = [Bool];
KeepInCache = [Bool]; NB: If true, the FX will always stay in cache, even if no FX of this type is currently in use. Can save time but costs memory. Defaults to false;
DoNotCache = [Bool]; NB: If true, the FX won't get cache and will be recreated from config every time, which allows random values & variations but is more expensive. Defaults to false;
KeepInCache = [Bool]; NB: If true , the FX will always stay in cache, even if no FX of this type is currently in use. Can save time but costs memory. Ignored if DoNotCache is set to true. Defaults to false;
[FXSlotTemplate]
Type = alpha|color|rgb|hsl|hsv|scale|rotation|position|speed|volume|pitch;
View
@@ -108,6 +108,7 @@
#define orxFX_KZ_CONFIG_KEEP_IN_CACHE "KeepInCache"
#define orxFX_KZ_CONFIG_USE_ROTATION "UseRotation"
#define orxFX_KZ_CONFIG_USE_SCALE "UseScale"
#define orxFX_KZ_CONFIG_DO_NOT_CACHE "DoNotCache"
#define orxFX_KZ_LINEAR "linear"
#define orxFX_KZ_TRIANGLE "triangle"
@@ -591,41 +592,45 @@ orxFX *orxFASTCALL orxFX_CreateFromConfig(const orxSTRING _zConfigID)
/* Valid? */
if(pstResult != orxNULL)
{
/* Adds it to reference table */
if(orxHashTable_Add(sstFX.pstReferenceTable, u32ID, pstResult) != orxSTATUS_FAILURE)
{
/* Stores its reference */
pstResult->zReference = orxConfig_GetCurrentSection();
/* Stores its reference */
pstResult->zReference = orxConfig_GetCurrentSection();
/* Processes its data */
if(orxFX_ProcessData(pstResult) != orxSTATUS_FAILURE)
/* Processes its data */
if(orxFX_ProcessData(pstResult) != orxSTATUS_FAILURE)
{
/* Can be cached? */
if(orxConfig_GetBool(orxFX_KZ_CONFIG_DO_NOT_CACHE) == orxFALSE)
{
/* Should keep it in cache? */
if(orxConfig_GetBool(orxFX_KZ_CONFIG_KEEP_IN_CACHE) != orxFALSE)
/* Adds it to reference table */
if(orxHashTable_Add(sstFX.pstReferenceTable, u32ID, pstResult) != orxSTATUS_FAILURE)
{
/* Increases its reference counter to keep it in cache table */
orxStructure_IncreaseCounter(pstResult);
/* Should keep it in cache? */
if(orxConfig_GetBool(orxFX_KZ_CONFIG_KEEP_IN_CACHE) != orxFALSE)
{
/* Increases its reference counter to keep it in cache table */
orxStructure_IncreaseCounter(pstResult);
/* Updates its flags */
orxStructure_SetFlags(pstResult, orxFX_KU32_FLAG_CACHED, orxFX_KU32_FLAG_NONE);
/* Updates its flags */
orxStructure_SetFlags(pstResult, orxFX_KU32_FLAG_CACHED, orxFX_KU32_FLAG_NONE);
}
}
}
else
{
/* Logs message */
orxDEBUG_PRINT(orxDEBUG_LEVEL_OBJECT, "Can't create FX <%s>: invalid content.", _zConfigID);
else
{
/* Logs message */
orxDEBUG_PRINT(orxDEBUG_LEVEL_OBJECT, "Failed to add FX to hashtable.");
/* Deletes it */
orxFX_Delete(pstResult);
/* Deletes it */
orxFX_Delete(pstResult);
/* Updates result */
pstResult = orxNULL;
/* Updates result */
pstResult = orxNULL;
}
}
}
else
{
/* Logs message */
orxDEBUG_PRINT(orxDEBUG_LEVEL_OBJECT, "Failed to add FX to hashtable.");
orxDEBUG_PRINT(orxDEBUG_LEVEL_OBJECT, "Can't create FX <%s>: invalid content.", _zConfigID);
/* Deletes it */
orxFX_Delete(pstResult);
@@ -397,7 +397,8 @@ KeepInCache = [Bool]; NB: If true, the sound data (ie. the sample itself) will a
[FXTemplate]
SlotList = FXSlotTemplate1 # FXSlotTemplate2 # ...; NB: There is a maximum of 8 slots;
Loop = [Bool];
KeepInCache = [Bool]; NB: If true, the FX will always stay in cache, even if no FX of this type is currently in use. Can save time but costs memory. Defaults to false;
DoNotCache = [Bool]; NB: If true, the FX won't get cache and will be recreated from config every time, which allows random values & variations but is more expensive. Defaults to false;
KeepInCache = [Bool]; NB: If true , the FX will always stay in cache, even if no FX of this type is currently in use. Can save time but costs memory. Ignored if DoNotCache is set to true. Defaults to false;
[FXSlotTemplate]
Type = alpha|color|rgb|hsl|hsv|scale|rotation|position|speed|volume|pitch;

0 comments on commit 08093f1

Please sign in to comment.