Don't cast away const when we can avoid it

post_malone
Andrei Kortunov 3 years ago
parent 6609243c87
commit fe785ea788

@ -115,7 +115,7 @@ class ESMWriter
void writeT(const T& data)
{
static_assert(!std::is_pointer_v<T>);
write((char*)&data, sizeof(T));
write(reinterpret_cast<const char*>(&data), sizeof(T));
}
template<typename T, std::size_t size>

@ -22,7 +22,10 @@ public:
}
Utf8Stream (const char * str) :
cur ((unsigned char*) str), nxt ((unsigned char*) str), end ((unsigned char*) str + strlen(str)), val(Utf8Stream::sBadChar())
cur (reinterpret_cast<const unsigned char*>(str)),
nxt (reinterpret_cast<const unsigned char*>(str)),
end (reinterpret_cast<const unsigned char*>(str) + strlen(str)),
val(Utf8Stream::sBadChar())
{
}

@ -137,9 +137,9 @@ public:
}
else
{
glVertexPointer(3, GL_FLOAT, sizeof(MyGUI::Vertex), (char*)vbo->getArray(0)->getDataPointer());
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(MyGUI::Vertex), (char*)vbo->getArray(0)->getDataPointer() + 12);
glTexCoordPointer(2, GL_FLOAT, sizeof(MyGUI::Vertex), (char*)vbo->getArray(0)->getDataPointer() + 16);
glVertexPointer(3, GL_FLOAT, sizeof(MyGUI::Vertex), reinterpret_cast<const char*>(vbo->getArray(0)->getDataPointer()));
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(MyGUI::Vertex), reinterpret_cast<const char*>(vbo->getArray(0)->getDataPointer()) + 12);
glTexCoordPointer(2, GL_FLOAT, sizeof(MyGUI::Vertex), reinterpret_cast<const char*>(vbo->getArray(0)->getDataPointer()) + 16);
}
glDrawArrays(GL_TRIANGLES, 0, batch.mVertexCount);

@ -1284,7 +1284,7 @@ namespace NifOsg
if (strip.size() < 3)
continue;
geometry->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_STRIP, strip.size(),
(unsigned short*)strip.data()));
reinterpret_cast<const unsigned short*>(strip.data())));
hasGeometry = true;
}
if (!hasGeometry)
@ -1299,7 +1299,7 @@ namespace NifOsg
if (line.empty())
return;
geometry->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::LINES, line.size(),
(unsigned short*)line.data()));
reinterpret_cast<const unsigned short*>(line.data())));
}
handleNiGeometryData(geometry, niGeometryData, boundTextures, nifNode->name);

Loading…
Cancel
Save