mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Split Mesh:attachAttribute(name, nil) out into Mesh:detachAttribute. Fix attachAttribute.
Don’t let me push commits on a friday night… --HG-- branch : minor
This commit is contained in:
@@ -311,24 +311,7 @@ bool Mesh::isAttributeEnabled(const std::string &name) const
|
||||
|
||||
void Mesh::attachAttribute(const std::string &name, Mesh *mesh, const std::string &attachname)
|
||||
{
|
||||
AttachedAttribute oldattrib = {};
|
||||
|
||||
auto it = attachedAttributes.find(name);
|
||||
if (it != attachedAttributes.end())
|
||||
oldattrib = it->second;
|
||||
|
||||
if (mesh == nullptr)
|
||||
{
|
||||
if (it != attachedAttributes.end() && oldattrib.mesh != this)
|
||||
{
|
||||
oldattrib.mesh->release();
|
||||
attachedAttributes.erase(it);
|
||||
if (getAttributeIndex(name) != -1)
|
||||
attachAttribute(name, this, name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (mesh != this)
|
||||
if (mesh != this)
|
||||
{
|
||||
for (const auto &it : mesh->attachedAttributes)
|
||||
{
|
||||
@@ -339,7 +322,13 @@ void Mesh::attachAttribute(const std::string &name, Mesh *mesh, const std::strin
|
||||
}
|
||||
}
|
||||
|
||||
AttachedAttribute oldattrib = {};
|
||||
AttachedAttribute newattrib = {};
|
||||
|
||||
auto it = attachedAttributes.find(name);
|
||||
if (it != attachedAttributes.end())
|
||||
oldattrib = it->second;
|
||||
|
||||
newattrib.mesh = mesh;
|
||||
newattrib.enabled = oldattrib.mesh ? oldattrib.enabled : true;
|
||||
newattrib.index = mesh->getAttributeIndex(attachname);
|
||||
@@ -356,6 +345,24 @@ void Mesh::attachAttribute(const std::string &name, Mesh *mesh, const std::strin
|
||||
oldattrib.mesh->release();
|
||||
}
|
||||
|
||||
bool Mesh::detachAttribute(const std::string &name)
|
||||
{
|
||||
auto it = attachedAttributes.find(name);
|
||||
|
||||
if (it != attachedAttributes.end() && it->second.mesh != this)
|
||||
{
|
||||
it->second.mesh->release();
|
||||
attachedAttributes.erase(it);
|
||||
|
||||
if (getAttributeIndex(name) != -1)
|
||||
attachAttribute(name, this, name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void *Mesh::mapVertexData()
|
||||
{
|
||||
return vbo->map();
|
||||
|
||||
Reference in New Issue
Block a user