cleaned up duplicated doom3 light_radius default value

git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@72 8a3a26a2-13c4-0310-b231-cf6edde360e5
This commit is contained in:
spog 2006-05-29 12:22:34 +00:00
parent 501f88301a
commit 4a43142e7f
3 changed files with 24 additions and 9 deletions

View file

@ -1,6 +1,10 @@
This is the changelog for developers, != changelog for the end user This is the changelog for developers, != changelog for the end user
that we distribute with the binaries. (see changelog) that we distribute with the binaries. (see changelog)
29/05/2006
SPoG
- Changed default doom3 light_radius to be taken from the entity-definition.
13/05/2006 13/05/2006
LordHavoc LordHavoc
- Added -fPIC for Linux builds to support x86_64. - Added -fPIC for Linux builds to support x86_64.

View file

@ -537,25 +537,30 @@ public:
typedef MemberCaller1<LightRadii, const char*, &LightRadii::flagsChanged> FlagsChangedCaller; typedef MemberCaller1<LightRadii, const char*, &LightRadii::flagsChanged> FlagsChangedCaller;
}; };
const Vector3 c_defaultDoom3LightRadius = Vector3(300, 300, 300);
class Doom3LightRadius class Doom3LightRadius
{ {
public: public:
Vector3 m_defaultRadius;
Vector3 m_radius; Vector3 m_radius;
Vector3 m_radiusTransformed; Vector3 m_radiusTransformed;
Vector3 m_center; Vector3 m_center;
Callback m_changed; Callback m_changed;
bool m_useCenterKey; bool m_useCenterKey;
Doom3LightRadius() : m_radius(c_defaultDoom3LightRadius), m_center(0, 0, 0), m_useCenterKey(false) Doom3LightRadius(const char* defaultRadius) : m_defaultRadius(300, 300, 300), m_center(0, 0, 0), m_useCenterKey(false)
{ {
if(!string_parse_vector3(defaultRadius, m_defaultRadius))
{
globalErrorStream() << "Doom3LightRadius: failed to parse default light radius\n";
}
m_radius = m_defaultRadius;
} }
void lightRadiusChanged(const char* value) void lightRadiusChanged(const char* value)
{ {
if(!string_parse_vector3(value, m_radius)) if(!string_parse_vector3(value, m_radius))
{ {
m_radius = c_defaultDoom3LightRadius; m_radius = m_defaultRadius;
} }
m_radiusTransformed = m_radius; m_radiusTransformed = m_radius;
m_changed(); m_changed();
@ -1043,6 +1048,7 @@ public:
m_named(m_entity), m_named(m_entity),
m_nameKeys(m_entity), m_nameKeys(m_entity),
m_funcStaticOrigin(m_traverse, m_originKey.m_origin), m_funcStaticOrigin(m_traverse, m_originKey.m_origin),
m_doom3Radius(EntityClass_valueForKey(m_entity.getEntityClass(), "light_radius")),
m_radii_wire(m_radii, m_aabb_light.origin), m_radii_wire(m_radii, m_aabb_light.origin),
m_radii_fill(m_radii, m_aabb_light.origin), m_radii_fill(m_radii, m_aabb_light.origin),
m_radii_box(m_aabb_light.origin), m_radii_box(m_aabb_light.origin),
@ -1066,6 +1072,7 @@ public:
m_named(m_entity), m_named(m_entity),
m_nameKeys(m_entity), m_nameKeys(m_entity),
m_funcStaticOrigin(m_traverse, m_originKey.m_origin), m_funcStaticOrigin(m_traverse, m_originKey.m_origin),
m_doom3Radius(EntityClass_valueForKey(m_entity.getEntityClass(), "light_radius")),
m_radii_wire(m_radii, m_aabb_light.origin), m_radii_wire(m_radii, m_aabb_light.origin),
m_radii_fill(m_radii, m_aabb_light.origin), m_radii_fill(m_radii, m_aabb_light.origin),
m_radii_box(m_aabb_light.origin), m_radii_box(m_aabb_light.origin),
@ -1330,7 +1337,7 @@ public:
write_rotation(m_rotationKey.m_rotation, &m_entity); write_rotation(m_rotationKey.m_rotation, &m_entity);
m_doom3Radius.m_radius = m_doom3Radius.m_radiusTransformed; m_doom3Radius.m_radius = m_doom3Radius.m_radiusTransformed;
if(m_doom3Radius.m_radius == c_defaultDoom3LightRadius) if(m_doom3Radius.m_radius == m_doom3Radius.m_defaultRadius)
{ {
m_entity.setKeyValue("light_radius", ""); m_entity.setKeyValue("light_radius", "");
} }

View file

@ -178,23 +178,27 @@ void Entity_connectSelected()
} }
} }
const float Doom3Light_defaultRadius = 300;
AABB Doom3Light_getBounds(const AABB& workzone) AABB Doom3Light_getBounds(const AABB& workzone)
{ {
AABB aabb(workzone); AABB aabb(workzone);
Vector3 defaultRadius(300, 300, 300);
if(!string_parse_vector3(EntityClass_valueForKey(*GlobalEntityClassManager().findOrInsert("light", false), "light_radius"), defaultRadius))
{
globalErrorStream() << "Doom3Light_getBounds: failed to parse default light radius\n";
}
if(aabb.extents[0] == 0) if(aabb.extents[0] == 0)
{ {
aabb.extents[0] = Doom3Light_defaultRadius; aabb.extents[0] = defaultRadius[0];
} }
if(aabb.extents[1] == 0) if(aabb.extents[1] == 0)
{ {
aabb.extents[1] = Doom3Light_defaultRadius; aabb.extents[1] = defaultRadius[1];
} }
if(aabb.extents[2] == 0) if(aabb.extents[2] == 0)
{ {
aabb.extents[2] = Doom3Light_defaultRadius; aabb.extents[2] = defaultRadius[2];
} }
if(aabb_valid(aabb)) if(aabb_valid(aabb))