Speedup for COBJMeshWriter

Avoiding some memory allocations.


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6213 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2021-05-06 15:01:05 +00:00
parent 678e06baeb
commit e611f2c571
2 changed files with 10 additions and 18 deletions

@ -1,5 +1,6 @@
--------------------------
Changes in 1.9 (not yet released)
- Speedup for COBJMeshWriter
- Add blinkMode parameter to IGUIEnvironment::addModalScreen, so blinking can be suppressed
- Speedup: Avoid string copy in CXMLReaderImpl::getAttributeByName
- Fix bug in rect::clipAgainst that had caused rects completely outside to the left-top of the rect to be clipped against ending up with both corners outside.

@ -244,34 +244,25 @@ bool COBJMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla
void COBJMeshWriter::getVectorAsStringLine(const core::vector3df& v, core::stringc& s) const
{
s = core::stringc(-v.X);
s += " ";
s += core::stringc(v.Y);
s += " ";
s += core::stringc(v.Z);
s += "\n";
c8 tmpbuf[255];
snprintf_irr(tmpbuf, 255, "%f %f %f\n", -v.X, v.Y, v.Z);
s = tmpbuf;
}
void COBJMeshWriter::getVectorAsStringLine(const core::vector2df& v, core::stringc& s) const
{
s = core::stringc(v.X);
s += " ";
s += core::stringc(1-v.Y);
s += "\n";
c8 tmpbuf[255];
snprintf_irr(tmpbuf, 255, "%f %f\n", v.X, 1.f-v.Y);
s = tmpbuf;
}
void COBJMeshWriter::getColorAsStringLine(const video::SColor& color, const c8* const prefix, core::stringc& s) const
{
s = prefix;
s += " ";
s += core::stringc((double)(color.getRed()/255.f));
s += " ";
s += core::stringc((double)(color.getGreen()/255.f));
s += " ";
s += core::stringc((double)(color.getBlue()/255.f));
s += "\n";
c8 tmpbuf[255];
snprintf_irr(tmpbuf, 255, "%s %f %f %f\n", prefix, (float)(color.getRed()/255.f), (float)(color.getGreen()/255.f), (float)(color.getBlue()/255.f));
s = tmpbuf;
}