Notice of Upcoming Update affecting ambient generic entities

Started by wallworm, September 02, 2020, 07:39:50 PM

Previous topic - Next topic

wallworm

I'm going to add an update to WW soon that has a visual helper for the radius of some entity parameters (like for env_soundscape and ambient_generic). The problem is that to do this correctly, I need to make sure that the parameters for these functions are float values. Unfortunately, due to the way the FGD files are written, the radius parameter for some entities (ambient_generic, for example) were stored as strings instead of floats. In my update, these will convert to floats. But here is the catch--the update to Custom Attributes that changes a parameter type does not allow the current value to propagate. This means that any existing scenes will get the default value applied to all ambient_generic radius values.

I can write a function that can embed the current value that can later be retrieved into the updated entities, but it must be done on a scene BEFORE updating to the version of WW that has these entity updates.

I want to try and get an idea about how many people this will affect as well as how many scenes. I need to know if it's worth my time to built this function.

Joris Ceoen

Quote from: wallworm on September 02, 2020, 07:39:50 PMI want to try and get an idea about how many people this will affect as well as how many scenes. I need to know if it's worth my time to built this function.
For me, specifically for Daigo, won't be a problem because I hadn't any ambient_generic entities. Not sure about other entities (prop_static also have a radius option for visibility optimization), but I'm 100% positive I haven't dabbled with any of the radius values on any possible entity in my scene, aka they're all the default as it is in Hammer.

wallworm

The FGD data made the radius be a string (with text input) for several entities :

radius(string) : "Max Audible Distance" : "1250" : "Maximum distance at which this sound is audible."

Here are the entities that I see this problem going to occur from base.fgd :


  • ambient_generic
  • env_physexplosion
  • physics_cannister
  • trigger_proximity

Joris Ceoen


wallworm

I am about to release an update to Wall Worm with this change. Below is a MAXScript that you can run before updating to store the current values that will be affected:

/*
struct WallWormEntityDataTypeHelper (
--values stored as strings that will be converted to floats in a custom attribute update and we need to store it because
stringsThatWillBeFloats = #("radius"), --make array in case we add more in future
/*
This script will embed entity parameters that are strings but will be converted to floats in a custom attribute update.
This is necessary because when a custom attribute parameter type is changed, it's current value is not kept (converted) but reverts to parameter default value.
*/
function storeCurrentValues = (
local updatedEnts = #()
for ent in ::WallWormHelperOps.entities WHERE isvalidnode ent do (
local ca = ::WallWormEntityOps.getEntCA ent
if ca != undefined then (
for p in stringsThatWillBeFloats do (
if isProperty ca p then (
local v = (getProperty ca p)
if classof v != float then (
setUserProp ent (("wallworm_entity_store_"+p) as name) (v as string)
append updatedEnts ent
)
)
)
)
)
if updatedEnts.count > 0 then (
selectionSets["Entities that Stored old values"] = updatedEnts
)
),
function retrieveOldValues = (
if ::WallWormHelperOps.entities.count > 0 then (
local paramsToCheck = #()
for p in stringsThatWillBeFloats do (
append paramsToCheck (datapair p (("wallworm_entity_store_"+p) as name))
)
for ent in ::WallWormHelperOps.entities WHERE isvalidnode ent do (
local ca = ::WallWormEntityOps.getEntCA ent
if ca != undefined then (
for p in paramsToCheck do (
local storedVal = getUserProp ent p.v2
if storedVal != undefined AND storeVal != "" then (
if isProperty ca p.v1 then (
--do a try because we cannot guarantee the string value can be converted to the data type
try (
setProperty ca p.v1 (storedVal as (classof (getProperty ca p.v1)))
) catch (
format "ERROR: Could not set % to % in %\n" p.v1 storedVal ent
)
)
)
)
)
)
)
)
)

::WallWormEntityDataTypeHelper = WallWormEntityDataTypeHelper()


To use this

  • click Scripting > New Script
  • Paste that code into your MAXScript File
  • Click Tools > Evaluate All (CTRL+E)
  • In the MAXScript Listener (F11) paste this code and then hit ENTER: ::WallWormEntityDataTypeHelper.storeCurrentValues()

Now the script will store the current values.

To retrieve the values after you update Wall Worm, you can then run this command in the MAXScript listener:
::WallWormEntityDataTypeHelper.retrieveOldValues()


IMPORTANT NOTE: You must run this code before updating to Wall Worm 5.0.41+ on each scene that you want to preserve the radius values of entities. If you do not have entities that use the radius parameter (or the radius was already defined as a float in the FGD you are using), you do not need to concern with this script.

SMF spam blocked by CleanTalk