Fixed headless mode.
Allow StringHash & ShortStringHash to be constructed implicitly. Code cleanup related to the above.
This commit is contained in:
Родитель
ce562fb894
Коммит
34df8b5e82
|
@ -234,8 +234,8 @@ void Variant::FromString(VariantType type, const char* value)
|
|||
{
|
||||
SetType(VAR_RESOURCEREF);
|
||||
ResourceRef& ref = *(reinterpret_cast<ResourceRef*>(&value_));
|
||||
ref.type_ = ShortStringHash(values[0]);
|
||||
ref.id_ = StringHash(values[1]);
|
||||
ref.type_ = values[0];
|
||||
ref.id_ = values[1];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -247,10 +247,10 @@ void Variant::FromString(VariantType type, const char* value)
|
|||
{
|
||||
SetType(VAR_RESOURCEREFLIST);
|
||||
ResourceRefList& refList = *(reinterpret_cast<ResourceRefList*>(&value_));
|
||||
refList.type_ = ShortStringHash(values[0]);
|
||||
refList.type_ = values[0];
|
||||
refList.ids_.Resize(values.Size() - 1);
|
||||
for (unsigned i = 1; i < values.Size(); ++i)
|
||||
refList.ids_[i - 1] = StringHash(values[i]);
|
||||
refList.ids_[i - 1] = values[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -119,7 +119,7 @@ struct ResourceRef
|
|||
|
||||
/// Object type.
|
||||
ShortStringHash type_;
|
||||
/// Object identifier, for example name hash.
|
||||
/// Object identifier (name hash.)
|
||||
StringHash id_;
|
||||
|
||||
/// Test for equality with another reference.
|
||||
|
@ -150,7 +150,7 @@ struct ResourceRefList
|
|||
|
||||
/// Object type.
|
||||
ShortStringHash type_;
|
||||
/// List of object identifiers, for example name hashes.
|
||||
/// List of object identifiers (name hashes.)
|
||||
Vector<StringHash> ids_;
|
||||
|
||||
/// Test for equality with another reference list.
|
||||
|
@ -165,21 +165,7 @@ class Variant;
|
|||
typedef Vector<Variant> VariantVector;
|
||||
|
||||
/// Map of variants.
|
||||
class VariantMap : public HashMap<ShortStringHash, Variant>
|
||||
{
|
||||
public:
|
||||
/// Index the map by string hash. Create a new pair if key not found.
|
||||
Variant& operator [] (const ShortStringHash& key)
|
||||
{
|
||||
return HashMap<ShortStringHash, Variant>::operator [] (key);
|
||||
}
|
||||
|
||||
/// Index the map by string. Create a new pair if key not found.
|
||||
Variant& operator [] (const String& key)
|
||||
{
|
||||
return HashMap<ShortStringHash, Variant>::operator [] (ShortStringHash(key));
|
||||
}
|
||||
};
|
||||
typedef HashMap<ShortStringHash, Variant> VariantMap;
|
||||
|
||||
/// Variable that supports a fixed set of types.
|
||||
class Variant
|
||||
|
|
|
@ -403,17 +403,17 @@ template <class T> void RegisterComponent(asIScriptEngine* engine, const char* c
|
|||
|
||||
static Component* NodeCreateComponent(const String& typeName, CreateMode mode, Node* ptr)
|
||||
{
|
||||
return ptr->CreateComponent(ShortStringHash(typeName), mode);
|
||||
return ptr->CreateComponent(typeName, mode);
|
||||
}
|
||||
|
||||
static Component* NodeGetOrCreateComponent(const String& typeName, CreateMode mode, Node* ptr)
|
||||
{
|
||||
return ptr->GetOrCreateComponent(ShortStringHash(typeName), mode);
|
||||
return ptr->GetOrCreateComponent(typeName, mode);
|
||||
}
|
||||
|
||||
static void NodeRemoveComponent(const String& typeName, Node* ptr)
|
||||
{
|
||||
ptr->RemoveComponent(ShortStringHash(typeName));
|
||||
ptr->RemoveComponent(typeName);
|
||||
}
|
||||
|
||||
static Component* NodeGetComponent(unsigned index, Node* ptr)
|
||||
|
@ -430,7 +430,7 @@ static Component* NodeGetComponent(unsigned index, Node* ptr)
|
|||
|
||||
static Component* NodeGetComponentWithType(const String& typeName, Node* ptr)
|
||||
{
|
||||
return ptr->GetComponent(ShortStringHash(typeName));
|
||||
return ptr->GetComponent(typeName);
|
||||
}
|
||||
|
||||
static CScriptArray* NodeGetComponents(Node* ptr)
|
||||
|
@ -441,13 +441,13 @@ static CScriptArray* NodeGetComponents(Node* ptr)
|
|||
static CScriptArray* NodeGetComponentsWithType(const String& typeName, bool recursive, Node* ptr)
|
||||
{
|
||||
PODVector<Component*> components;
|
||||
ptr->GetComponents(components, ShortStringHash(typeName), recursive);
|
||||
ptr->GetComponents(components, typeName, recursive);
|
||||
return VectorToHandleArray<Component>(components, "Array<Component@>");
|
||||
}
|
||||
|
||||
static bool NodeHasComponent(const String& typeName, Node* ptr)
|
||||
{
|
||||
return ptr->HasComponent(ShortStringHash(typeName));
|
||||
return ptr->HasComponent(typeName);
|
||||
}
|
||||
|
||||
static CScriptArray* NodeGetChildren(bool recursive, Node* ptr)
|
||||
|
@ -460,7 +460,7 @@ static CScriptArray* NodeGetChildren(bool recursive, Node* ptr)
|
|||
static CScriptArray* NodeGetChildrenWithComponent(String& typeName, bool recursive, Node* ptr)
|
||||
{
|
||||
PODVector<Node*> nodes;
|
||||
ptr->GetChildrenWithComponent(nodes, ShortStringHash(typeName), recursive);
|
||||
ptr->GetChildrenWithComponent(nodes, typeName, recursive);
|
||||
return VectorToHandleArray<Node>(nodes, "Array<Node@>");
|
||||
}
|
||||
|
||||
|
@ -776,7 +776,7 @@ static bool UIElementSaveXML(File* file, UIElement* ptr)
|
|||
|
||||
static UIElement* UIElementCreateChild(const String& typeName, const String& name, UIElement* ptr)
|
||||
{
|
||||
return ptr->CreateChild(ShortStringHash(typeName), name);
|
||||
return ptr->CreateChild(typeName, name);
|
||||
}
|
||||
|
||||
static void UIElementRemoveChild(UIElement* child, unsigned index, UIElement* ptr)
|
||||
|
|
|
@ -361,12 +361,12 @@ static Variant& VariantMapAtHash(ShortStringHash key, VariantMap& map)
|
|||
|
||||
static bool VariantMapContains(const String& key, VariantMap& map)
|
||||
{
|
||||
return map.Contains(ShortStringHash(key));
|
||||
return map.Contains(key);
|
||||
}
|
||||
|
||||
static bool VariantMapErase(const String& key, VariantMap& map)
|
||||
{
|
||||
return map.Erase(ShortStringHash(key));
|
||||
return map.Erase(key);
|
||||
}
|
||||
|
||||
static bool VariantMapContainsHash(ShortStringHash key, VariantMap& map)
|
||||
|
@ -665,35 +665,35 @@ static void SendEvent(const String& eventType, VariantMap& eventData)
|
|||
{
|
||||
Object* sender = GetScriptContextEventListenerObject();
|
||||
if (sender)
|
||||
sender->SendEvent(StringHash(eventType), eventData);
|
||||
sender->SendEvent(eventType, eventData);
|
||||
}
|
||||
|
||||
static void SubscribeToEvent(const String& eventType, const String& handlerName)
|
||||
{
|
||||
ScriptEventListener* listener = GetScriptContextEventListener();
|
||||
if (listener)
|
||||
listener->AddEventHandler(StringHash(eventType), handlerName);
|
||||
listener->AddEventHandler(eventType, handlerName);
|
||||
}
|
||||
|
||||
static void SubscribeToSenderEvent(Object* sender, const String& eventType, const String& handlerName)
|
||||
{
|
||||
ScriptEventListener* listener = GetScriptContextEventListener();
|
||||
if (listener)
|
||||
listener->AddEventHandler(sender, StringHash(eventType), handlerName);
|
||||
listener->AddEventHandler(sender, eventType, handlerName);
|
||||
}
|
||||
|
||||
static void UnsubscribeFromEvent(const String& eventType)
|
||||
{
|
||||
Object* listener = GetScriptContextEventListenerObject();
|
||||
if (listener)
|
||||
listener->UnsubscribeFromEvent(StringHash(eventType));
|
||||
listener->UnsubscribeFromEvent(eventType);
|
||||
}
|
||||
|
||||
static void UnsubscribeFromSenderEvent(Object* sender, const String& eventType)
|
||||
{
|
||||
Object* listener = GetScriptContextEventListenerObject();
|
||||
if (listener)
|
||||
listener->UnsubscribeFromEvent(sender, StringHash(eventType));
|
||||
listener->UnsubscribeFromEvent(sender, eventType);
|
||||
}
|
||||
|
||||
static void UnsubscribeFromSenderEvents(Object* sender)
|
||||
|
|
|
@ -106,6 +106,9 @@ bool Engine::Initialize(const VariantMap& parameters)
|
|||
if (initialized_)
|
||||
return true;
|
||||
|
||||
// Set headless mode
|
||||
headless_ = GetParameter(parameters, "Headless", false).GetBool();
|
||||
|
||||
// Register object factories and attributes first, then subsystems
|
||||
RegisterObjects();
|
||||
RegisterSubsystems();
|
||||
|
|
|
@ -77,12 +77,12 @@ static void RegisterNetworkPriority(asIScriptEngine* engine)
|
|||
|
||||
void SendRemoteEvent(const String& eventType, bool inOrder, const VariantMap& eventData, Connection* ptr)
|
||||
{
|
||||
ptr->SendRemoteEvent(StringHash(eventType), inOrder, eventData);
|
||||
ptr->SendRemoteEvent(eventType, inOrder, eventData);
|
||||
}
|
||||
|
||||
void SendRemoteNodeEvent(Node* receiver, const String& eventType, bool inOrder, const VariantMap& eventData, Connection* ptr)
|
||||
{
|
||||
ptr->SendRemoteEvent(receiver, StringHash(eventType), inOrder, eventData);
|
||||
ptr->SendRemoteEvent(receiver, eventType, inOrder, eventData);
|
||||
}
|
||||
|
||||
static void RegisterConnection(asIScriptEngine* engine)
|
||||
|
@ -131,32 +131,32 @@ static CScriptArray* NetworkGetClientConnections(Network* ptr)
|
|||
|
||||
static void NetworkBroadcastRemoteEvent(const String& eventType, bool inOrder, const VariantMap& eventData, Network* ptr)
|
||||
{
|
||||
ptr->BroadcastRemoteEvent(StringHash(eventType), inOrder, eventData);
|
||||
ptr->BroadcastRemoteEvent(eventType, inOrder, eventData);
|
||||
}
|
||||
|
||||
static void NetworkBroadcastRemoteSceneEvent(Scene* scene, const String& eventType, bool inOrder, const VariantMap& eventData, Network* ptr)
|
||||
{
|
||||
ptr->BroadcastRemoteEvent(scene, StringHash(eventType), inOrder, eventData);
|
||||
ptr->BroadcastRemoteEvent(scene, eventType, inOrder, eventData);
|
||||
}
|
||||
|
||||
static void NetworkBroadcastRemoteNodeEvent(Node* node, const String& eventType, bool inOrder, const VariantMap& eventData, Network* ptr)
|
||||
{
|
||||
ptr->BroadcastRemoteEvent(node, StringHash(eventType), inOrder, eventData);
|
||||
ptr->BroadcastRemoteEvent(node, eventType, inOrder, eventData);
|
||||
}
|
||||
|
||||
static void NetworkRegisterRemoteEvent(const String& eventType, Network* ptr)
|
||||
{
|
||||
ptr->RegisterRemoteEvent(StringHash(eventType));
|
||||
ptr->RegisterRemoteEvent(eventType);
|
||||
}
|
||||
|
||||
static void NetworkUnregisterRemoteEvent(const String& eventType, Network* ptr)
|
||||
{
|
||||
ptr->UnregisterRemoteEvent(StringHash(eventType));
|
||||
ptr->UnregisterRemoteEvent(eventType);
|
||||
}
|
||||
|
||||
static bool NetworkCheckRemoteEvent(const String& eventType, Network* ptr)
|
||||
{
|
||||
return ptr->CheckRemoteEvent(StringHash(eventType));
|
||||
return ptr->CheckRemoteEvent(eventType);
|
||||
}
|
||||
|
||||
void RegisterNetwork(asIScriptEngine* engine)
|
||||
|
|
|
@ -38,7 +38,7 @@ void RegisterResource(asIScriptEngine* engine)
|
|||
|
||||
static Resource* ResourceCacheGetResource(const String& type, const String& name, ResourceCache* ptr)
|
||||
{
|
||||
return ptr->GetResource(ShortStringHash(type), name);
|
||||
return ptr->GetResource(type, name);
|
||||
}
|
||||
|
||||
static File* ResourceCacheGetFile(const String& name, ResourceCache* ptr)
|
||||
|
@ -53,32 +53,32 @@ static File* ResourceCacheGetFile(const String& name, ResourceCache* ptr)
|
|||
|
||||
static void ResourceCacheReleaseResource(const String& type, const String& name, bool force, ResourceCache* ptr)
|
||||
{
|
||||
ptr->ReleaseResource(ShortStringHash(type), name, force);
|
||||
ptr->ReleaseResource(type, name, force);
|
||||
}
|
||||
|
||||
static void ResourceCacheReleaseResources(const String& type, bool force, ResourceCache* ptr)
|
||||
{
|
||||
ptr->ReleaseResources(ShortStringHash(type), force);
|
||||
ptr->ReleaseResources(type, force);
|
||||
}
|
||||
|
||||
static void ResourceCacheReleaseResourcesPartial(const String& type, const String& partialName, bool force, ResourceCache* ptr)
|
||||
{
|
||||
ptr->ReleaseResources(ShortStringHash(type), partialName, force);
|
||||
ptr->ReleaseResources(type, partialName, force);
|
||||
}
|
||||
|
||||
static void ResourceCacheSetMemoryBudget(const String& type, unsigned budget, ResourceCache* ptr)
|
||||
{
|
||||
ptr->SetMemoryBudget(ShortStringHash(type), budget);
|
||||
ptr->SetMemoryBudget(type, budget);
|
||||
}
|
||||
|
||||
static unsigned ResourceCacheGetMemoryBudget(const String& type, ResourceCache* ptr)
|
||||
{
|
||||
return ptr->GetMemoryBudget(ShortStringHash(type));
|
||||
return ptr->GetMemoryBudget(type);
|
||||
}
|
||||
|
||||
static unsigned ResourceCacheGetMemoryUse(const String& type, ResourceCache* ptr)
|
||||
{
|
||||
return ptr->GetMemoryUse(ShortStringHash(type));
|
||||
return ptr->GetMemoryUse(type);
|
||||
}
|
||||
|
||||
static ResourceCache* GetResourceCache()
|
||||
|
|
|
@ -590,18 +590,12 @@ AnimationState* AnimatedModel::GetAnimationState(Animation* animation) const
|
|||
|
||||
AnimationState* AnimatedModel::GetAnimationState(const String& animationName) const
|
||||
{
|
||||
for (Vector<SharedPtr<AnimationState> >::ConstIterator i = animationStates_.Begin(); i != animationStates_.End(); ++i)
|
||||
{
|
||||
Animation* animation = (*i)->GetAnimation();
|
||||
if (animation)
|
||||
{
|
||||
// Check both the animation and the resource name
|
||||
if (animation->GetName() == animationName || animation->GetAnimationName() == animationName)
|
||||
return *i;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return GetAnimationState(StringHash(animationName));
|
||||
}
|
||||
|
||||
AnimationState* AnimatedModel::GetAnimationState(const char* animationName) const
|
||||
{
|
||||
return GetAnimationState(StringHash(animationName));
|
||||
}
|
||||
|
||||
AnimationState* AnimatedModel::GetAnimationState(StringHash animationNameHash) const
|
||||
|
|
|
@ -105,6 +105,8 @@ public:
|
|||
AnimationState* GetAnimationState(Animation* animation) const;
|
||||
/// Return animation state by animation name.
|
||||
AnimationState* GetAnimationState(const String& animationName) const;
|
||||
/// Return animation state by animation name.
|
||||
AnimationState* GetAnimationState(const char* animationName) const;
|
||||
/// Return animation state by animation name hash.
|
||||
AnimationState* GetAnimationState(const StringHash animationNameHash) const;
|
||||
/// Return animation state by index.
|
||||
|
|
|
@ -90,7 +90,7 @@ bool Animation::Load(Deserializer& source)
|
|||
|
||||
// Read name and length
|
||||
animationName_ = source.ReadString();
|
||||
animationNameHash_ = StringHash(animationName_);
|
||||
animationNameHash_ = animationName_;
|
||||
length_ = source.ReadFloat();
|
||||
tracks_.Clear();
|
||||
|
||||
|
@ -103,7 +103,7 @@ bool Animation::Load(Deserializer& source)
|
|||
{
|
||||
AnimationTrack& newTrack = tracks_[i];
|
||||
newTrack.name_ = source.ReadString();
|
||||
newTrack.nameHash_ = StringHash(newTrack.name_);
|
||||
newTrack.nameHash_ = newTrack.name_;
|
||||
newTrack.channelMask_ = source.ReadUByte();
|
||||
|
||||
unsigned keyFrames = source.ReadUInt();
|
||||
|
|
|
@ -295,10 +295,10 @@ void Material::SetShaderParameter(const String& name, const Vector4& value)
|
|||
MaterialShaderParameter newParam;
|
||||
newParam.name_ = name;
|
||||
newParam.value_ = value;
|
||||
StringHash stringHash(name);
|
||||
shaderParameters_[stringHash] = newParam;
|
||||
StringHash nameHash(name);
|
||||
shaderParameters_[nameHash] = newParam;
|
||||
|
||||
if (stringHash == PSP_MATSPECCOLOR)
|
||||
if (nameHash == PSP_MATSPECCOLOR)
|
||||
specular_ = value.x_ > 0.0f || value.y_ > 0.0f || value.z_ > 0.0f;
|
||||
}
|
||||
|
||||
|
@ -360,10 +360,10 @@ void Material::SetDepthBias(const BiasParameters& parameters)
|
|||
|
||||
void Material::RemoveShaderParameter(const String& name)
|
||||
{
|
||||
StringHash stringHash(name);
|
||||
shaderParameters_.Erase(stringHash);
|
||||
StringHash nameHash(name);
|
||||
shaderParameters_.Erase(nameHash);
|
||||
|
||||
if (stringHash == PSP_MATSPECCOLOR)
|
||||
if (nameHash == PSP_MATSPECCOLOR)
|
||||
specular_ = false;
|
||||
}
|
||||
|
||||
|
@ -421,7 +421,7 @@ Texture* Material::GetTexture(TextureUnit unit) const
|
|||
|
||||
const Vector4& Material::GetShaderParameter(const String& name) const
|
||||
{
|
||||
HashMap<StringHash, MaterialShaderParameter>::ConstIterator i = shaderParameters_.Find(StringHash(name));
|
||||
HashMap<StringHash, MaterialShaderParameter>::ConstIterator i = shaderParameters_.Find(name);
|
||||
return i != shaderParameters_.End() ? i->second_.value_ : Vector4::ZERO;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ bool Model::Load(Deserializer& source)
|
|||
ModelMorph newMorph;
|
||||
|
||||
newMorph.name_ = source.ReadString();
|
||||
newMorph.nameHash_ = StringHash(newMorph.name_);
|
||||
newMorph.nameHash_ = newMorph.name_;
|
||||
newMorph.weight_ = 0.0f;
|
||||
unsigned nubuffers_ = source.ReadUInt();
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ void RenderPathCommand::LoadParameters(const XMLElement& element)
|
|||
break;
|
||||
|
||||
case CMD_SCENEPASS:
|
||||
pass_ = StringHash(element.GetAttribute("pass"));
|
||||
pass_ = element.GetAttribute("pass");
|
||||
sortMode_ = (RenderCommandSortMode)GetStringListIndex(element.GetAttributeLower("sort"), sortModeNames, SORT_FRONTTOBACK);
|
||||
if (element.HasAttribute("marktostencil"))
|
||||
markToStencil_ = element.GetBool("marktostencil");
|
||||
|
@ -144,7 +144,7 @@ void RenderPathCommand::LoadParameters(const XMLElement& element)
|
|||
{
|
||||
String name = parameterElem.GetAttribute("name");
|
||||
Vector4 value = parameterElem.GetVector("value");
|
||||
shaderParameters_[StringHash(name)] = value;
|
||||
shaderParameters_[name] = value;
|
||||
|
||||
parameterElem = parameterElem.GetNext("parameter");
|
||||
}
|
||||
|
@ -203,12 +203,12 @@ void RenderPathCommand::SetTextureName(TextureUnit unit, const String& name)
|
|||
|
||||
void RenderPathCommand::SetShaderParameter(const String& name, const Vector4& value)
|
||||
{
|
||||
shaderParameters_[StringHash(name)] = value;
|
||||
shaderParameters_[name] = value;
|
||||
}
|
||||
|
||||
void RenderPathCommand::RemoveShaderParameter(const String& name)
|
||||
{
|
||||
shaderParameters_.Erase(StringHash(name));
|
||||
shaderParameters_.Erase(name);
|
||||
}
|
||||
|
||||
void RenderPathCommand::SetNumOutputs(unsigned num)
|
||||
|
@ -232,7 +232,7 @@ const String& RenderPathCommand::GetTextureName(TextureUnit unit) const
|
|||
|
||||
const Vector4& RenderPathCommand::GetShaderParameter(const String& name) const
|
||||
{
|
||||
HashMap<StringHash, Vector4>::ConstIterator i = shaderParameters_.Find(StringHash(name));
|
||||
HashMap<StringHash, Vector4>::ConstIterator i = shaderParameters_.Find(name);
|
||||
return i != shaderParameters_.End() ? i->second_ : Vector4::ZERO;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ bool Skeleton::Load(Deserializer& source)
|
|||
{
|
||||
Bone newBone;
|
||||
newBone.name_ = source.ReadString();
|
||||
newBone.nameHash_ = StringHash(newBone.name_);
|
||||
newBone.nameHash_ = newBone.name_;
|
||||
newBone.parentIndex_ = source.ReadUInt();
|
||||
newBone.initialPosition_ = source.ReadVector3();
|
||||
newBone.initialRotation_ = source.ReadQuaternion();
|
||||
|
|
|
@ -1400,7 +1400,7 @@ void View::SetTextures(const RenderPathCommand& command)
|
|||
}
|
||||
|
||||
// Bind a rendertarget
|
||||
HashMap<StringHash, Texture2D*>::ConstIterator j = renderTargets_.Find(StringHash(command.textureNames_[i]));
|
||||
HashMap<StringHash, Texture2D*>::ConstIterator j = renderTargets_.Find(command.textureNames_[i]);
|
||||
if (j != renderTargets_.End())
|
||||
{
|
||||
graphics_->SetTexture(i, j->second_);
|
||||
|
@ -1461,11 +1461,11 @@ void View::RenderQuad(const RenderPathCommand& command)
|
|||
float width = (float)renderTargets_[nameHash]->GetWidth();
|
||||
float height = (float)renderTargets_[nameHash]->GetHeight();
|
||||
|
||||
graphics_->SetShaderParameter(StringHash(invSizeName), Vector4(1.0f / width, 1.0f / height, 0.0f, 0.0f));
|
||||
graphics_->SetShaderParameter(invSizeName, Vector4(1.0f / width, 1.0f / height, 0.0f, 0.0f));
|
||||
#ifdef USE_OPENGL
|
||||
graphics_->SetShaderParameter(StringHash(offsetsName), Vector4::ZERO);
|
||||
graphics_->SetShaderParameter(offsetsName, Vector4::ZERO);
|
||||
#else
|
||||
graphics_->SetShaderParameter(StringHash(offsetsName), Vector4(0.5f / width, 0.5f / height, 0.0f, 0.0f));
|
||||
graphics_->SetShaderParameter(offsetsName, Vector4(0.5f / width, 0.5f / height, 0.0f, 0.0f));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1559,7 +1559,7 @@ void View::AllocateScreenBuffers()
|
|||
height = rtSize_.y_ / (height ? height : 1);
|
||||
}
|
||||
|
||||
renderTargets_[StringHash(rtInfo.name_)] = renderer_->GetScreenBuffer(width, height, rtInfo.format_, rtInfo.filtered_, rtInfo.sRGB_);
|
||||
renderTargets_[rtInfo.name_] = renderer_->GetScreenBuffer(width, height, rtInfo.format_, rtInfo.filtered_, rtInfo.sRGB_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ bool PackageFile::Open(const String& fileName)
|
|||
}
|
||||
|
||||
fileName_ = fileName;
|
||||
nameHash_ = StringHash(fileName_);
|
||||
nameHash_ = fileName_;
|
||||
totalSize_ = file->GetSize();
|
||||
|
||||
unsigned numFiles = file->ReadUInt();
|
||||
|
|
|
@ -50,10 +50,9 @@ public:
|
|||
}
|
||||
|
||||
/// Construct from a C string case-insensitively.
|
||||
explicit StringHash(const char* str);
|
||||
|
||||
StringHash(const char* str);
|
||||
/// Construct from a string case-insensitively.
|
||||
explicit StringHash(const String& str);
|
||||
StringHash(const String& str);
|
||||
|
||||
/// Assign from another hash.
|
||||
StringHash& operator = (const StringHash& rhs)
|
||||
|
@ -134,9 +133,9 @@ public:
|
|||
}
|
||||
|
||||
/// Construct from a C string case-insensitively.
|
||||
explicit ShortStringHash(const char* str);
|
||||
ShortStringHash(const char* str);
|
||||
/// Construct from a string case-insensitively.
|
||||
explicit ShortStringHash(const String& str);
|
||||
ShortStringHash(const String& str);
|
||||
|
||||
/// Assign from another hash.
|
||||
ShortStringHash& operator = (const ShortStringHash& rhs)
|
||||
|
@ -188,7 +187,4 @@ private:
|
|||
unsigned short value_;
|
||||
};
|
||||
|
||||
#define HASH(str) (StringHash(#str))
|
||||
#define SHORTHASH(str) (ShortStringHash(#str))
|
||||
|
||||
}
|
||||
|
|
|
@ -1352,7 +1352,7 @@ void Connection::RequestPackage(const String& name, unsigned fileSize, unsigned
|
|||
void Connection::SendPackageError(const String& name)
|
||||
{
|
||||
msg_.Clear();
|
||||
msg_.WriteStringHash(StringHash(name));
|
||||
msg_.WriteStringHash(name);
|
||||
SendMessage(MSG_PACKAGEDATA, true, false, msg_);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ bool Resource::Save(Serializer& dest)
|
|||
void Resource::SetName(const String& name)
|
||||
{
|
||||
name_ = name;
|
||||
nameHash_ = StringHash(name);
|
||||
nameHash_ = name;
|
||||
}
|
||||
|
||||
void Resource::SetMemoryUse(unsigned size)
|
||||
|
|
|
@ -393,6 +393,11 @@ Resource* ResourceCache::GetResource(ShortStringHash type, const String& nameIn)
|
|||
return GetResource(type, StringHash(name));
|
||||
}
|
||||
|
||||
Resource* ResourceCache::GetResource(ShortStringHash type, const char* name)
|
||||
{
|
||||
return GetResource(type, String(name));
|
||||
}
|
||||
|
||||
Resource* ResourceCache::GetResource(ShortStringHash type, StringHash nameHash)
|
||||
{
|
||||
// If null hash, return null pointer immediately
|
||||
|
@ -605,7 +610,7 @@ void ResourceCache::StoreResourceDependency(Resource* resource, const String& de
|
|||
return;
|
||||
|
||||
StringHash nameHash(resource->GetName());
|
||||
HashSet<StringHash>& dependents = dependentResources_[StringHash(dependency)];
|
||||
HashSet<StringHash>& dependents = dependentResources_[dependency];
|
||||
dependents.Insert(nameHash);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,8 @@ public:
|
|||
SharedPtr<File> GetFile(const String& name);
|
||||
/// Return a resource by type and name. Load if not loaded yet. Return null if fails.
|
||||
Resource* GetResource(ShortStringHash type, const String& name);
|
||||
/// Return a resource by type and name. Load if not loaded yet. Return null if fails.
|
||||
Resource* GetResource(ShortStringHash type, const char* name);
|
||||
/// Return a resource by type and name hash. Load if not loaded yet. Return null if fails.
|
||||
Resource* GetResource(ShortStringHash type, StringHash nameHash);
|
||||
/// Return all loaded resources of a specific type.
|
||||
|
@ -105,6 +107,8 @@ public:
|
|||
const Vector<SharedPtr<PackageFile> >& GetPackageFiles() const { return packages_; }
|
||||
/// Template version of returning a resource by name.
|
||||
template <class T> T* GetResource(const String& name);
|
||||
/// Template version of returning a resource by name.
|
||||
template <class T> T* GetResource(const char* name);
|
||||
/// Template version of returning a resource by name hash.
|
||||
template <class T> T* GetResource(StringHash nameHash);
|
||||
/// Template version of returning loaded resources of a specific type.
|
||||
|
@ -171,6 +175,12 @@ template <class T> T* ResourceCache::GetResource(const String& name)
|
|||
return static_cast<T*>(GetResource(type, name));
|
||||
}
|
||||
|
||||
template <class T> T* ResourceCache::GetResource(const char* name)
|
||||
{
|
||||
ShortStringHash type = T::GetTypeStatic();
|
||||
return static_cast<T*>(GetResource(type, name));
|
||||
}
|
||||
|
||||
template <class T> T* ResourceCache::GetResource(StringHash nameHash)
|
||||
{
|
||||
ShortStringHash type = T::GetTypeStatic();
|
||||
|
|
|
@ -589,8 +589,8 @@ ResourceRef XMLElement::GetResourceRef() const
|
|||
Vector<String> values = String::Split(GetAttribute("value"), ';');
|
||||
if (values.Size() == 2)
|
||||
{
|
||||
ret.type_ = ShortStringHash(values[0]);
|
||||
ret.id_ = StringHash(values[1]);
|
||||
ret.type_ = values[0];
|
||||
ret.id_ = values[1];
|
||||
|
||||
// Whenever we encounter a resource name read from a ResourceRef XML element, store the reverse mapping to
|
||||
// ResourceCache if possible. We will probably use the hash to request a resource shortly afterward
|
||||
|
@ -612,7 +612,7 @@ ResourceRefList XMLElement::GetResourceRefList() const
|
|||
// ResourceCache if possible. We will probably use the hashes to request resources shortly afterward
|
||||
ResourceCache* cache = file_ ? file_->GetSubsystem<ResourceCache>() : 0;
|
||||
|
||||
ret.type_ = ShortStringHash(values[0]);
|
||||
ret.type_ = values[0];
|
||||
ret.ids_.Resize(values.Size() - 1);
|
||||
for (unsigned i = 1; i < values.Size(); ++i)
|
||||
{
|
||||
|
|
|
@ -220,7 +220,7 @@ bool Node::SaveXML(Serializer& dest)
|
|||
void Node::SetName(const String& name)
|
||||
{
|
||||
name_ = name;
|
||||
nameHash_ = StringHash(name);
|
||||
nameHash_ = name_;
|
||||
|
||||
MarkNetworkUpdate();
|
||||
|
||||
|
@ -800,6 +800,11 @@ Node* Node::GetChild(const String& name, bool recursive) const
|
|||
return GetChild(StringHash(name), recursive);
|
||||
}
|
||||
|
||||
Node* Node::GetChild(const char* name, bool recursive) const
|
||||
{
|
||||
return GetChild(StringHash(name), recursive);
|
||||
}
|
||||
|
||||
Node* Node::GetChild(StringHash nameHash, bool recursive) const
|
||||
{
|
||||
for (Vector<SharedPtr<Node> >::ConstIterator i = children_.Begin(); i != children_.End(); ++i)
|
||||
|
@ -1044,7 +1049,7 @@ bool Node::LoadXML(const XMLElement& source, SceneResolver& resolver, bool readC
|
|||
{
|
||||
String typeName = compElem.GetAttribute("type");
|
||||
unsigned compID = compElem.GetInt("id");
|
||||
Component* newComponent = CreateComponent(ShortStringHash(typeName),
|
||||
Component* newComponent = CreateComponent(typeName,
|
||||
(mode == REPLICATED && compID < FIRST_LOCAL_ID) ? REPLICATED : LOCAL, rewriteIDs ? 0 : compID);
|
||||
if (newComponent)
|
||||
{
|
||||
|
|
|
@ -252,6 +252,8 @@ public:
|
|||
Node* GetChild(unsigned index) const;
|
||||
/// Return child scene node by name.
|
||||
Node* GetChild(const String& name, bool recursive = false) const;
|
||||
/// Return child scene node by name.
|
||||
Node* GetChild(const char* name, bool recursive = false) const;
|
||||
/// Return child scene node by name hash.
|
||||
Node* GetChild(StringHash nameHash, bool recursive = false) const;
|
||||
/// Return number of components.
|
||||
|
|
|
@ -431,12 +431,12 @@ void Scene::ClearRequiredPackageFiles()
|
|||
|
||||
void Scene::RegisterVar(const String& name)
|
||||
{
|
||||
varNames_[ShortStringHash(name)] = name;
|
||||
varNames_[name] = name;
|
||||
}
|
||||
|
||||
void Scene::UnregisterVar(const String& name)
|
||||
{
|
||||
varNames_.Erase(ShortStringHash(name));
|
||||
varNames_.Erase(name);
|
||||
}
|
||||
|
||||
void Scene::UnregisterAllVars()
|
||||
|
@ -740,7 +740,7 @@ void Scene::SetVarNamesAttr(String value)
|
|||
|
||||
varNames_.Clear();
|
||||
for (Vector<String>::ConstIterator i = varNames.Begin(); i != varNames.End(); ++i)
|
||||
varNames_[ShortStringHash(*i)] = *i;
|
||||
varNames_[*i] = *i;
|
||||
}
|
||||
|
||||
String Scene::GetVarNamesAttr() const
|
||||
|
|
|
@ -124,11 +124,11 @@ bool Menu::LoadXML(const XMLElement& source, XMLFile* styleFile)
|
|||
if (!internalElem)
|
||||
{
|
||||
if (!popupElem)
|
||||
child = CreateChild(ShortStringHash(typeName));
|
||||
child = CreateChild(typeName);
|
||||
else
|
||||
{
|
||||
// Do not add the popup element as a child even temporarily, as that can break layouts
|
||||
SharedPtr<UIElement> popup = DynamicCast<UIElement>(context_->CreateObject(ShortStringHash(typeName)));
|
||||
SharedPtr<UIElement> popup = DynamicCast<UIElement>(context_->CreateObject(typeName));
|
||||
if (!popup)
|
||||
LOGERROR("Could not create popup element type " + ShortStringHash(typeName).ToString());
|
||||
else
|
||||
|
|
|
@ -374,7 +374,7 @@ SharedPtr<UIElement> UI::LoadLayout(XMLFile* file, XMLFile* styleFile)
|
|||
if (typeName.Empty())
|
||||
typeName = "UIElement";
|
||||
|
||||
root = DynamicCast<UIElement>(context_->CreateObject(ShortStringHash(typeName)));
|
||||
root = DynamicCast<UIElement>(context_->CreateObject(typeName));
|
||||
if (!root)
|
||||
{
|
||||
LOGERROR("Could not create unknown UI element " + typeName);
|
||||
|
|
|
@ -241,7 +241,7 @@ bool UIElement::LoadXML(const XMLElement& source, XMLFile* styleFile)
|
|||
UIElement* child = 0;
|
||||
|
||||
if (!internalElem)
|
||||
child = CreateChild(ShortStringHash(typeName));
|
||||
child = CreateChild(typeName);
|
||||
else
|
||||
{
|
||||
for (unsigned i = nextInternalChild; i < children_.Size(); ++i)
|
||||
|
|
|
@ -864,7 +864,7 @@ void BuildAndSaveAnimations(OutModel& model)
|
|||
|
||||
AnimationTrack track;
|
||||
track.name_ = channelName;
|
||||
track.nameHash_ = StringHash(channelName);
|
||||
track.nameHash_ = channelName;
|
||||
|
||||
// Check which channels are used
|
||||
track.channelMask_ = 0;
|
||||
|
|
Загрузка…
Ссылка в новой задаче