diff --git a/README.md b/README.md index 37fdd4fd..860ece98 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ / /_/ // __ |/ / / // __ \ / __ \ / __ `__ \ /_ < / __ |/ /_ / / __ / _, _// /_/ // /_/ // /_/ // /_/ // / / / / /___/ // /_/ // __/ / /_/ / /_/ |_|/_____//_____/ \____/ \____//_/ /_/ /_//____//_____//_/ \____/ -_________________________________________ +_______________________________________________________________________ ``` RBDOOM-3-BFG Readme - https://github.com/RobertBeckebans/RBDOOM-3-BFG diff --git a/neo/d3xp/Game.h b/neo/d3xp/Game.h index c5ce5e19..505f12a7 100644 --- a/neo/d3xp/Game.h +++ b/neo/d3xp/Game.h @@ -245,7 +245,7 @@ public: // Animation system calls for non-game based skeletal rendering. virtual idRenderModel* ANIM_GetModelFromEntityDef( const char* classname ); - virtual const idVec3& ANIM_GetModelOffsetFromEntityDef( const char* classname ); + virtual const idVec3& ANIM_GetModelOffsetFromEntityDef( const char* classname ); virtual idRenderModel* ANIM_GetModelFromEntityDef( const idDict* args ); virtual idRenderModel* ANIM_GetModelFromName( const char* modelName ); virtual const idMD5Anim* ANIM_GetAnimFromEntityDef( const char* classname, const char* animname ); @@ -305,6 +305,7 @@ public: virtual void MapSave( const char* path = NULL ) const; virtual void MapSetEntityKeyVal( const char* name, const char* key, const char* val ) const ; virtual void MapCopyDictToEntity( const char* name, const idDict* dict ) const; + virtual void MapCopyDictToEntityAtOrigin( const idVec3& org, const idDict* dict ) const; virtual int MapGetUniqueMatchingKeyVals( const char* key, const char* list[], const int max ) const; virtual void MapAddEntity( const idDict* dict ) const; virtual int MapGetEntitiesMatchingClassWithString( const char* classname, const char* match, const char* list[], const int max ) const; diff --git a/neo/d3xp/GameEdit.cpp b/neo/d3xp/GameEdit.cpp index 09df5bae..0eb4fa02 100644 --- a/neo/d3xp/GameEdit.cpp +++ b/neo/d3xp/GameEdit.cpp @@ -1202,6 +1202,40 @@ void idGameEdit::MapCopyDictToEntity( const char* name, const idDict* dict ) con } } +/* +================ +RB idGameEdit::MapCopyDictToEntityAtOrigin +================ +*/ +void idGameEdit::MapCopyDictToEntityAtOrigin( const idVec3& origin, const idDict* dict ) const +{ + idMapFile* mapFile = gameLocal.GetLevelMap(); + if( mapFile )//&& name && *name ) + { + idMapEntity* mapent = mapFile->FindEntityAtOrigin( origin ); + if( mapent ) + { + for( int i = 0; i < dict->GetNumKeyVals(); i++ ) + { + const idKeyValue* kv = dict->GetKeyVal( i ); + const char* key = kv->GetKey(); + const char* val = kv->GetValue(); + + // DG: if val is "", delete key from the entity + // => same behavior as EntityChangeSpawnArgs() + if( val[0] == '\0' ) + { + mapent->epairs.Delete( key ); + } + else + { + mapent->epairs.Set( key, val ); + } + // DG end + } + } + } +} /* diff --git a/neo/idlib/MapFile.cpp b/neo/idlib/MapFile.cpp index 86871a87..381d3a22 100644 --- a/neo/idlib/MapFile.cpp +++ b/neo/idlib/MapFile.cpp @@ -1598,6 +1598,31 @@ idMapEntity* idMapFile::FindEntity( const char* name ) return NULL; } +/* +=============== +RB idMapFile::FindEntityAtOrigin +=============== +*/ +idMapEntity* idMapFile::FindEntityAtOrigin( const idVec3& org ) +{ + idBounds bo( org ); + bo.ExpandSelf( 0.125f ); + + for( int i = 0; i < entities.Num(); i++ ) + { + idMapEntity* ent = entities[i]; + + idVec3 entPos; + ent->epairs.GetVector( "origin", "", entPos ); + + if( bo.ContainsPoint( entPos ) ) + { + return ent; + } + } + return NULL; +} + /* =============== idMapFile::RemoveEntity diff --git a/neo/idlib/MapFile.h b/neo/idlib/MapFile.h index 702d3c35..5f1dbd57 100644 --- a/neo/idlib/MapFile.h +++ b/neo/idlib/MapFile.h @@ -502,6 +502,7 @@ public: int AddEntity( idMapEntity* mapentity ); idMapEntity* FindEntity( const char* name ); + idMapEntity* FindEntityAtOrigin( const idVec3& org ); // RB void RemoveEntity( idMapEntity* mapEnt ); void RemoveEntities( const char* classname ); void RemoveAllEntities(); diff --git a/neo/tools/imgui/lighteditor/LightEditor.cpp b/neo/tools/imgui/lighteditor/LightEditor.cpp index 96ef4cd0..3f00e76d 100644 --- a/neo/tools/imgui/lighteditor/LightEditor.cpp +++ b/neo/tools/imgui/lighteditor/LightEditor.cpp @@ -324,17 +324,19 @@ void LightEditor::Init( const idDict* dict, idEntity* light ) original.FromDict( dict ); cur.FromDict( dict ); + gameEdit->EntityGetOrigin( light, entityPos ); + const char* name = dict->GetString( "name", NULL ); if( name ) { entityName = name; - title.Format( "Light Editor: %s", name ); + title.Format( "Light Editor: %s at (%s)", name, entityPos.ToString() ); } else { - idassert( 0 && "LightEditor::Init(): Given entity has no 'name' property?!" ); + //idassert( 0 && "LightEditor::Init(): Given entity has no 'name' property?!" ); entityName = ""; // TODO: generate name or handle gracefully or something? - title.Format( "Light Editor: light" ); + title.Format( "Light Editor: light at (%s)", entityPos.ToString() ); } currentTextureIndex = 0; @@ -359,14 +361,20 @@ void LightEditor::Init( const idDict* dict, idEntity* light ) currentStyleIndex = original.lightStyle + 1; } } + this->lightEntity = light; } void LightEditor::Reset() { title = "Light Editor: no Light selected!"; + entityPos.x = idMath::INFINITY; + entityPos.y = idMath::INFINITY; + entityPos.z = idMath::INFINITY; + original.Defaults(); cur.Defaults(); + lightEntity = NULL; currentTextureIndex = 0; currentTexture = NULL; @@ -520,21 +528,13 @@ void LightEditor::SaveChanges() { gameEdit->MapCopyDictToEntity( entityName, &d ); } - else + else if( entityPos.x != idMath::INFINITY ) { - assert( 0 && "FIXME: implement LightEditor::SaveChanges() properly for entities without names (new ones?)" ); - -#if 0 // TODO: I'm not quite sure about this, we prolly need to set a name before anyway for TempApplyChanges() - entityName = "light_42"; // FIXME: generate unique name!! - title.Format( "Light Editor: %s", entityName ); - + entityName = gameEdit->GetUniqueEntityName( "light" ); d.Set( "name", entityName ); - d.Set( "classname", "light" ); - d.Set( "spawnclass", "idLight" ); - - gameEdit->MapAddEntity( &d ); -#endif // 0 + // RB: this is really HACKY + gameEdit->MapCopyDictToEntityAtOrigin( entityPos, &d ); } gameEdit->MapSave(); diff --git a/neo/tools/imgui/lighteditor/LightEditor.h b/neo/tools/imgui/lighteditor/LightEditor.h index edf57b48..e5acc653 100644 --- a/neo/tools/imgui/lighteditor/LightEditor.h +++ b/neo/tools/imgui/lighteditor/LightEditor.h @@ -60,11 +60,6 @@ public: #if 0 // FIXME: unused, delete? bool fog; idVec4 fogDensity; - - bool strobe; - float strobeSpeed; - bool rotate; - float rotateSpeed; #endif // 0 idVec3 lightRadius; @@ -86,8 +81,10 @@ public: class LightEditor { private: - idStr title; - idStr entityName; + idStr title; + idStr entityName; + idVec3 entityPos; + LightInfo original; LightInfo cur; // current status of the light