mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-22 09:40:46 +00:00
Let ingame light editor handle anonymous lights
This commit is contained in:
parent
1f2f6896e1
commit
288359067b
7 changed files with 82 additions and 24 deletions
|
@ -4,7 +4,7 @@
|
|||
/ /_/ // __ |/ / / // __ \ / __ \ / __ `__ \ /_ < / __ |/ /_ / / __
|
||||
/ _, _// /_/ // /_/ // /_/ // /_/ // / / / / /___/ // /_/ // __/ / /_/ /
|
||||
/_/ |_|/_____//_____/ \____/ \____//_/ /_/ /_//____//_____//_/ \____/
|
||||
_________________________________________
|
||||
_______________________________________________________________________
|
||||
```
|
||||
|
||||
RBDOOM-3-BFG Readme - https://github.com/RobertBeckebans/RBDOOM-3-BFG
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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: <unnamed> light" );
|
||||
title.Format( "Light Editor: <unnamed> 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();
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue