From fdc5e8760fb7ac0af8e7ebb98a2076db15e31082 Mon Sep 17 00:00:00 2001 From: aura Date: Mon, 16 Mar 2026 10:15:01 +0100 Subject: giga refactor, fix ALL the leaks --- src/editor/properties.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/editor/properties.h') diff --git a/src/editor/properties.h b/src/editor/properties.h index 34ac765..01edbbf 100644 --- a/src/editor/properties.h +++ b/src/editor/properties.h @@ -1,7 +1,6 @@ #pragma once #include "../gamedef.h" -#include #if IS_EDITOR #include @@ -34,9 +33,15 @@ enum EditorPropType_t { EPROP_I64, EPROP_F32, EPROP_F64, + EPROP_VEC2, + EPROP_VEC3, + EPROP_VEC4, + EPROP_CLR, + EPROP_MAPPROP, EPROP_STRING, EPROP_OBJ, EPROP_LIST, + EPROP_TEXTURE, EPROP_TEXTURE_LIST, }; @@ -72,6 +77,12 @@ struct EDITOR_PROP { template <> struct __eprop_type { static const U8 type = EPROP_F32; }; template <> struct __eprop_type { static const U8 type = EPROP_F64; }; template <> struct __eprop_type { static const U8 type = EPROP_STRING; }; + template <> struct __eprop_type { static const U8 type = EPROP_CLR; }; + template <> struct __eprop_type { static const U8 type = EPROP_VEC2; }; + template <> struct __eprop_type { static const U8 type = EPROP_VEC3; }; + template <> struct __eprop_type { static const U8 type = EPROP_VEC4; }; + template <> struct __eprop_type { static const U8 type = EPROP_MAPPROP; }; + template <> struct __eprop_type { static const U8 type = EPROP_TEXTURE; }; template <__eobject_base T> struct __eprop_type { static const U8 type = EPROP_OBJ; }; template struct __eprop_type> { static const U8 type = EPROP_LIST; }; template <> struct __eprop_type> { static const U8 type = EPROP_TEXTURE_LIST; }; -- cgit v1.2.3 From f1882249843caa8bd931ecb76bb489615e079b10 Mon Sep 17 00:00:00 2001 From: aura Date: Mon, 16 Mar 2026 12:51:06 +0100 Subject: editor work --- src/editor/properties.h | 75 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 11 deletions(-) (limited to 'src/editor/properties.h') diff --git a/src/editor/properties.h b/src/editor/properties.h index 01edbbf..1eb51f8 100644 --- a/src/editor/properties.h +++ b/src/editor/properties.h @@ -8,17 +8,22 @@ #define EPROP( _type, name, value, display ) \ _type name = value; \ - EDITOR_PROP name##_prop{ .pdata = &name, .type = eprop_type<_type>(), .displayname = display, .parent = this }; + EDITOR_PROP name##_prop{ &name, eprop_type<_type>(), display, this, 0 }; + +#define EPROP_RO( _type, name, value, display ) \ + _type name = value; \ + EDITOR_PROP name##_prop{ .pdata = &name, .type = eprop_type<_type>(), .displayname = display, .parent = this, .readonly = 1 }; #define EPROP_RANGED( _type, name, value, display, _min, _max ) \ _type name{ value }; \ EDITOR_PROP{ \ - .pdata = &name, \ - .type = eprop_type<_type>(), \ - .displayname = display, \ - .parent = this, \ - .min = _min, \ - .max = _max \ + &name, \ + eprop_type<_type>(), \ + display, \ + this, \ + _min, \ + _max, \ + 0 \ } enum EditorPropType_t { @@ -45,9 +50,13 @@ enum EditorPropType_t { EPROP_TEXTURE_LIST, }; +struct EPROP_ENTRY { + U64 offset; +}; + // editor map object struct EOBJECT { - LIST eprops{}; + LIST eprops{}; }; template @@ -55,13 +64,49 @@ concept __eobject_base = __is_base_of(EOBJECT, T); // editor object property struct EDITOR_PROP { - void* pdata; + EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, struct EOBJECT* _parent, U8 _readonly = 0 ) { + type = _type; + displayname = _displayname; + min = -INFINITY; + max = INFINITY; + readonly = _readonly; + + U64 _this = (U64)this; + U64 pdata = (U64)_pdata; + U64 parent = (U64)_parent; + U64 offset = _this - parent; + + _parent->eprops.push( { offset } ); + + offset = _this - pdata; + dataoff = offset; + } + + + EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, struct EOBJECT* _parent, F32 _min, F32 _max, U8 _readonly = 0 ) { + type = _type; + displayname = _displayname; + min = _min; + max = _max; + readonly = _readonly; + + U64 _this = (U64)this; + U64 pdata = (U64)_pdata; + U64 parent = (U64)_parent; + U64 offset = _this - parent; + + _parent->eprops.push( { offset } ); + + offset = _this - pdata; + dataoff = offset; + } + + U64 dataoff; U8 type; STR displayname; F64 min{ -INFINITY }; F64 max{ INFINITY }; - struct EOBJECT* parent; - + U8 readonly; template struct __eprop_type { static const U8 type = EPROP_INVALID; @@ -88,6 +133,14 @@ struct EDITOR_PROP { template <> struct __eprop_type> { static const U8 type = EPROP_TEXTURE_LIST; }; }; +inline EDITOR_PROP* eprop_from_ref( EOBJECT* obj, EPROP_ENTRY e ) { + return (EDITOR_PROP*)( (U64)obj + e.offset ); +} + +inline void* eprop_ptr( EDITOR_PROP* prop ) { + return (void*)( (U64)prop - prop->dataoff); +} + template const U8 eprop_type() { return EDITOR_PROP::__eprop_type::type; -- cgit v1.2.3 From 991352b0d2767e6bd1a46f554db4ac9d208c13ad Mon Sep 17 00:00:00 2001 From: aura Date: Mon, 16 Mar 2026 15:40:03 +0100 Subject: finish prop rewrite --- src/editor/properties.h | 76 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 72 insertions(+), 4 deletions(-) (limited to 'src/editor/properties.h') diff --git a/src/editor/properties.h b/src/editor/properties.h index 1eb51f8..d663a6b 100644 --- a/src/editor/properties.h +++ b/src/editor/properties.h @@ -8,15 +8,15 @@ #define EPROP( _type, name, value, display ) \ _type name = value; \ - EDITOR_PROP name##_prop{ &name, eprop_type<_type>(), display, this, 0 }; + EDITOR_PROP name##_prop{ &name, eprop_type<_type>(), display, this, 0 } #define EPROP_RO( _type, name, value, display ) \ _type name = value; \ - EDITOR_PROP name##_prop{ .pdata = &name, .type = eprop_type<_type>(), .displayname = display, .parent = this, .readonly = 1 }; + EDITOR_PROP name##_prop{ &name, eprop_type<_type>(), display, this, 1 } #define EPROP_RANGED( _type, name, value, display, _min, _max ) \ - _type name{ value }; \ - EDITOR_PROP{ \ + _type name = value; \ + EDITOR_PROP name##_prop{ \ &name, \ eprop_type<_type>(), \ display, \ @@ -26,6 +26,30 @@ 0 \ } +#define EPROP_STEP( _type, name, value, display, step ) \ + _type name = value; \ + EDITOR_PROP name##_prop{ \ + &name, \ + eprop_type<_type>(), \ + display, \ + step, \ + this, \ + 0 \ + } + +#define EPROP_RANGED_STEP( _type, name, value, display, min, max, step ) \ + _type name = value; \ + EDITOR_PROP name##_prop{ \ + &name, \ + eprop_type<_type>(), \ + display, \ + step, \ + this, \ + min, \ + max, \ + 0 \ + } + enum EditorPropType_t { EPROP_INVALID = 0, EPROP_U8 = 1, @@ -48,6 +72,8 @@ enum EditorPropType_t { EPROP_LIST, EPROP_TEXTURE, EPROP_TEXTURE_LIST, + EPROP_VERTEX, + EPROP_VERTEX_LIST }; struct EPROP_ENTRY { @@ -69,6 +95,7 @@ struct EDITOR_PROP { displayname = _displayname; min = -INFINITY; max = INFINITY; + step = 0; readonly = _readonly; U64 _this = (U64)this; @@ -82,12 +109,50 @@ struct EDITOR_PROP { dataoff = offset; } + EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, F32 _step, struct EOBJECT* _parent, U8 _readonly = 0 ) { + type = _type; + displayname = _displayname; + min = -INFINITY; + max = INFINITY; + step = _step; + readonly = _readonly; + + U64 _this = (U64)this; + U64 pdata = (U64)_pdata; + U64 parent = (U64)_parent; + U64 offset = _this - parent; + + _parent->eprops.push( { offset } ); + + offset = _this - pdata; + dataoff = offset; + } EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, struct EOBJECT* _parent, F32 _min, F32 _max, U8 _readonly = 0 ) { type = _type; displayname = _displayname; min = _min; max = _max; + step = 0; + readonly = _readonly; + + U64 _this = (U64)this; + U64 pdata = (U64)_pdata; + U64 parent = (U64)_parent; + U64 offset = _this - parent; + + _parent->eprops.push( { offset } ); + + offset = _this - pdata; + dataoff = offset; + } + + EDITOR_PROP( void* _pdata, U8 _type, STR _displayname, F32 _step, struct EOBJECT* _parent, F32 _min, F32 _max, U8 _readonly = 0 ) { + type = _type; + displayname = _displayname; + min = _min; + max = _max; + step = _step; readonly = _readonly; U64 _this = (U64)this; @@ -106,6 +171,7 @@ struct EDITOR_PROP { STR displayname; F64 min{ -INFINITY }; F64 max{ INFINITY }; + F32 step; U8 readonly; template struct __eprop_type { @@ -131,6 +197,8 @@ struct EDITOR_PROP { template <__eobject_base T> struct __eprop_type { static const U8 type = EPROP_OBJ; }; template struct __eprop_type> { static const U8 type = EPROP_LIST; }; template <> struct __eprop_type> { static const U8 type = EPROP_TEXTURE_LIST; }; + template <> struct __eprop_type { static const U8 type = EPROP_VERTEX; }; + template <> struct __eprop_type> { static const U8 type = EPROP_VERTEX_LIST; }; }; inline EDITOR_PROP* eprop_from_ref( EOBJECT* obj, EPROP_ENTRY e ) { -- cgit v1.2.3