Merge pull request #1242 from HifiExperiments/entityProps

fix noNetwork and add documentation for automated entity property files
This commit is contained in:
HifiExperiments 2025-06-10 17:32:19 -07:00 committed by GitHub
commit 9b7b5a2bea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 80 additions and 13 deletions

View File

@ -51,11 +51,16 @@ macro(GENERATE_ENTITY_PROPERTIES)
file(STRINGS src/EntityItemProperties.txt ENTITY_PROPERTIES_FILE)
while(ENTITY_PROPERTIES_FILE)
list(POP_FRONT ENTITY_PROPERTIES_FILE LINE)
# Handle both trailing comments and full line comments
string(REGEX REPLACE " #.*$" "" LINE ${LINE})
string(REGEX REPLACE "#.*$" "" LINE ${LINE})
if(LINE STREQUAL "")
continue()
elseif(NOT LINE MATCHES ".*:.*")
# Single-word lines represent sections of properties, which can be base properties like "Physics" or
# Entity types like "Model". We use the section names to generate comments, and also handle indentation
# and opening/closing braces.
if(NOT LINE MATCHES ".*:.*")
if(LINE STREQUAL "Common")
set(COMMON_PROPS true)
else()
@ -108,11 +113,11 @@ macro(GENERATE_ENTITY_PROPERTIES)
endif()
if (NOT COMMON_PROPS)
string(CONCAT ${CURRENT_TYPE}_REQUESTED_PROPS "${${CURRENT_TYPE}_REQUESTED_PROPS}" "\t// ${LINE}\n")
string(CONCAT ${CURRENT_TYPE}_ENTITY_APPEND "${${CURRENT_TYPE}_ENTITY_APPEND}" "\t\t// ${LINE}\n")
string(CONCAT ${CURRENT_TYPE}_ENTITY_READ "${${CURRENT_TYPE}_ENTITY_READ}" "\t// ${LINE}\n")
string(CONCAT ${CURRENT_TYPE}_ENTITY_COPY_TO "${${CURRENT_TYPE}_ENTITY_COPY_TO}" "\t// ${LINE}\n")
if (NOT LOCAL_PROPS)
string(CONCAT ${CURRENT_TYPE}_REQUESTED_PROPS "${${CURRENT_TYPE}_REQUESTED_PROPS}" "\t// ${LINE}\n")
string(CONCAT ${CURRENT_TYPE}_ENTITY_SET_FROM "${${CURRENT_TYPE}_ENTITY_SET_FROM}" "\t// ${LINE}\n")
endif()
endif()
@ -298,7 +303,6 @@ macro(GENERATE_ENTITY_PROPERTIES)
string(CONCAT ENTITY_ITEM_PROPERTY_APPEND "${ENTITY_ITEM_PROPERTY_APPEND}" "\t\t\tAPPEND_ENTITY_PROPERTY(${ENTITY_PROPERTY_ENUM}, properties.get${ENTITY_PROPERTY_NAME_CAPS}());\n")
endif()
string(CONCAT ENTITY_ITEM_PROPERTY_READ "${ENTITY_ITEM_PROPERTY_READ}" "\tREAD_ENTITY_PROPERTY_TO_PROPERTIES(${ENTITY_PROPERTY_ENUM}, ${ENTITY_PROPERTY_READ_TYPE}, set${ENTITY_PROPERTY_NAME_CAPS});\n")
string(CONCAT ${CURRENT_TYPE}_REQUESTED_PROPS "${${CURRENT_TYPE}_REQUESTED_PROPS}" "\trequestedProperties += ${ENTITY_PROPERTY_ENUM};\n")
if(LINE MATCHES ".*enum( |,).*")
string(CONCAT ${CURRENT_TYPE}_ENTITY_APPEND "${${CURRENT_TYPE}_ENTITY_APPEND}" "\tAPPEND_ENTITY_PROPERTY(${ENTITY_PROPERTY_ENUM}, (uint8_t)get${ENTITY_PROPERTY_NAME_CAPS}());\n")
elseif(ENTITY_VARIABLE_NETWORK_GETTER)
@ -317,6 +321,9 @@ macro(GENERATE_ENTITY_PROPERTIES)
endif()
if (NOT COMMON_PROPS)
if (NOT LOCAL_PROPS)
string(CONCAT ${CURRENT_TYPE}_REQUESTED_PROPS "${${CURRENT_TYPE}_REQUESTED_PROPS}" "\trequestedProperties += ${ENTITY_PROPERTY_ENUM};\n")
endif()
set(VARIABLE_DEFINE_FUNC "DEFINE_VARIABLE_REF")
if(LINE MATCHES ".*noGetterSetterProp( |,).*")
set(VARIABLE_DEFINE_FUNC "DEFINE_VARIABLE_NO_GETTER_SETTER")
@ -426,9 +433,14 @@ macro(GENERATE_ENTITY_PROPERTIES)
file(STRINGS src/EntityItemGroupProperties.txt GROUP_PROPERTIES_FILE)
while(GROUP_PROPERTIES_FILE)
list(POP_FRONT GROUP_PROPERTIES_FILE LINE)
# Handle both trailing comments and full line comments
string(REGEX REPLACE " #.*$" "" LINE ${LINE})
string(REGEX REPLACE "#.*$" "" LINE ${LINE})
if(LINE STREQUAL "")
continue()
elseif(NOT LINE MATCHES ".*,")
# Lines that don't end in a comma represent the start of a new property group.
if(NOT LINE MATCHES ".*,")
string(REGEX MATCH ".*type:+([A-Z0-9a-z_<>::\/\.\"\(\)\+\-]+).*" GROUP_PROPERTY_TYPE ${LINE})
set(GROUP_PROPERTY_TYPE ${CMAKE_MATCH_1})

View File

@ -77,11 +77,6 @@ EntityPropertyFlags EntityItem::getEntityProperties(EncodeBitstreamParams& param
@Base_REQUESTED_PROPS@
// Some of the properties not transmitted over network need to be added manually here:
requestedProperties += PROP_ENTITY_HOST_TYPE;
requestedProperties += PROP_OWNING_AVATAR_ID;
requestedProperties += PROP_VISIBLE_IN_SECONDARY_CAMERA;
return requestedProperties;
}

View File

@ -1,3 +1,19 @@
# This file defines all of the behavior of group entity properties. Each line defines one group property.
# This is how each line is interpreted:
# 1. A single word with no spaces or commas: delimits a property group, e.g. "grab" or "animation"
# Can be followed by type:<camelcase actual type>: some groups have a different c++ file name, e.g. ring is RingGizmo. if this isn't specified, the group name is just capitalized, e.g. pulse to Pulse.
# 2. A space separated list of the following properties, ending in a comma, defines a single property:
# Required values:
# enum:<the c++ prop enum (not including the PROP_ prefix)>
# prop:<the actual property name>
# type:<the property type>
# default:<the default value>
# Optional values:
# min:<the min value>
# max:<the max value>
# Optional flags:
# enum: this is an enum value
# urlPermission: this property is a URL which should be guarded by the canViewAssetURLs permission
grab
enum:GRAB_GRABBABLE prop:grabbable type:bool default:INITIAL_GRABBABLE,
enum:GRAB_KINEMATIC prop:grabKinematic type:bool default:INITIAL_KINEMATIC,

View File

@ -1,3 +1,47 @@
# This file defines all of the behavior of non-group entity properties. Each line defines one property or property group.
# This is how each line is interpreted:
# 1. A single word with no spaces or commas: delimits a section of properties, e.g. "Physics" or "Scripts". After "Common", each line delimits a type of entity (e.g. "Shape", "Zone", "Web")
# 2. A space separated list of the following properties, ending in a comma, defines a single property:
# Required values:
# enum:<the c++ prop enum (not including the PROP_ prefix)>
# prop:<the actual property name>
# type:<the property type>
# default:<the default value>
# Optional values:
# min:<the min value>
# max:<the max value>
# fromScriptType:<the type to use when converting from script values, if different than the normal type>
# proxy:<if this is a proxy for another property, the name of the actual property>
# proxyType:<for a proxy prop, the type of the original property, if different from this prop's type>
# getter:<the name of the function to use when getting this property in EntityItemProperties, if different than the default>
# setter:<the name of the function to use when setting this property in EntityItemProperties, if different than the default>
# networkGetter:<the expression to use when appending this property to the network stream in EntityItemProperties>
# variableNetworkGetter:<the expression to use when appending this property to the network stream in XXXXEntityItem>
# variableNetworkSetter:<the expression to use when reading this property from the network stream in XXXXEntityItem>
# variableCopyGetter:<the expression to use when getting this property to go from XXXXEntityItem to EntityItemProperties>
# variableCopySetter:<the expression to use when setting this property to go from EntityItemProperties to XXXXEntityItem>
# readType:<the type to use when reading this property from the network in EntityItemProperties>
# debugString:<the string to append to the debug dump for this property, e.g. units>
# debugGetter:<the expression to use to get a debug representation of this property>
# Optional flags:
# legacy: this is a legacy property, i.e. a proxy for another value
# common: this is a common property that is shared by multiple Entity types
# enum: this is an enum value
# propertySetter: in EntityItemProperties, this property will implement its own setter
# noScript: this property is not exposed to scripts
# readOnly: this property is not settable from scripts
# noNetwork: this property is not sent over the network
# urlPermission: this property is a URL which should be guarded by the canViewAssetURLs permission
# noVariableNetworkSetter: in XXXXEntityItem::readEntityDataFromBuffer/readEntitySubclassDataFromBuffer, this property will implement its own network setter (must still maintain the order though)
# basicProp/renderProp/noGetterSetterProp/inherited: specifies how the getter + setter should be defined in XXXXEntityItem. a basicProp will define them for you and just directly store the data. a renderProp will set _needsRenderUpdate to true if the property changes. a noGetterSetterProp will define the member variable but not the getter/setter. an inherited prop will not define anything, assuming both the member variable and getter/setter are inherited. if none of these are specified, the member variable will be defined as well as the getter/setter, but you must implement the getter/setter in the .cpp file.
# 3. group:<lowercase group property name> followed by optional properties, followed by a comma: represents a property group which uses the group name for scripts
# Optional values:
# type:<camelcase actual type>: some groups have a different c++ file name, e.g. ring is RingGizmo. if this isn't specified, the group name is just capitalized, e.g. pulse to Pulse.
# Optional flags:
# common: if this is a "common" group, shared by multiple entity types
# renderUpdateOnSet/recordChange: renderUpdateOnSet, in setSubClassProperties, set _needsRenderUpdate to true to trigger a render update if any of the group properties change. if recordChange, set a member variable (e.g. _hazePropertiesChanged) to true if any of the group properties change
# customVariableSetFrom: specifies that the class implements its own handling of how to react to changes to this group in setSubClassProperties
# customVariableRead: specifies that the class implements its own handling of how to react to changes to this group in readEntitySubclassDataFromBuffer
Core
enum:SIMULATION_OWNER prop:simulationOwner type:SimulationOwner default:SimulationOwner() noScript readType:QByteArray networkGetter:properties._simulationOwner.toByteArray() variableNetworkGetter:_simulationOwner.toByteArray() noVariableNetworkSetter,
enum:PARENT_ID prop:parentID type:QUuid default:UNKNOWN_ENTITY_ID inherited variableNetworkGetter:actualParentID noVariableNetworkSetter,