mirror of https://github.com/axmolengine/axmol.git
Replace push_back() vs emplace_back() on axis/tests/cpp-tests and axis/core (#781)
* Replace push_back() vs emplace_back() on axis\tests\cpp-tests\ D:\______\GitHub\aismann\axis\tests\cpp-tests\Classes Replace Vector push_back() vs emplace_back() #762 * Replace push_back() vs emplace_back() on axis\core\ #781 * Update CCConsole.cpp * Update UIWebViewImpl-android.cpp * Update UIWebViewImpl-android.cpp
This commit is contained in:
parent
9ce38e060b
commit
376c80dd2d
|
@ -96,7 +96,7 @@ void PointArray::setControlPoints(vector<Vec2> controlPoints)
|
|||
|
||||
void PointArray::addControlPoint(const Vec2& controlPoint)
|
||||
{
|
||||
_controlPoints.push_back(controlPoint);
|
||||
_controlPoints.emplace_back(controlPoint);
|
||||
}
|
||||
|
||||
void PointArray::insertControlPoint(const Vec2& controlPoint, ssize_t index)
|
||||
|
@ -132,7 +132,7 @@ PointArray* PointArray::reverse() const
|
|||
newArray.reserve(_controlPoints.size());
|
||||
for (auto iter = _controlPoints.rbegin(), iterRend = _controlPoints.rend(); iter != iterRend; ++iter)
|
||||
{
|
||||
newArray.push_back(*iter);
|
||||
newArray.emplace_back(*iter);
|
||||
}
|
||||
PointArray* config = PointArray::create(0);
|
||||
config->setControlPoints(std::move(newArray));
|
||||
|
|
|
@ -2499,7 +2499,7 @@ bool Animate::initWithAnimation(Animation* animation)
|
|||
{
|
||||
float value = (accumUnitsOfTime * newUnitOfTimeValue) / singleDuration;
|
||||
accumUnitsOfTime += frame->getDelayUnits();
|
||||
_splitTimes->push_back(value);
|
||||
_splitTimes->emplace_back(value);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -355,7 +355,7 @@ std::vector<axis::Vec2> AutoPolygon::marchSquare(const Rect& rect, const Vec2& s
|
|||
// not found, we go up, and add to case9s;
|
||||
stepx = 0;
|
||||
stepy = -1;
|
||||
case9s.push_back(i);
|
||||
case9s.emplace_back(i);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
|
@ -382,7 +382,7 @@ std::vector<axis::Vec2> AutoPolygon::marchSquare(const Rect& rect, const Vec2& s
|
|||
// not found, we go up, and add to case9s;
|
||||
stepx = 1;
|
||||
stepy = 0;
|
||||
case6s.push_back(i);
|
||||
case6s.emplace_back(i);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -400,7 +400,7 @@ std::vector<axis::Vec2> AutoPolygon::marchSquare(const Rect& rect, const Vec2& s
|
|||
}
|
||||
else
|
||||
{
|
||||
_points.push_back(Vec2((float)(curx - rect.origin.x) / _scaleFactor,
|
||||
_points.emplace_back(Vec2((float)(curx - rect.origin.x) / _scaleFactor,
|
||||
(float)(rect.size.height - cury + rect.origin.y) / _scaleFactor));
|
||||
}
|
||||
|
||||
|
@ -471,8 +471,8 @@ std::vector<axis::Vec2> AutoPolygon::rdp(const std::vector<axis::Vec2>& v, float
|
|||
else
|
||||
{
|
||||
std::vector<Vec2> ret;
|
||||
ret.push_back(v.front());
|
||||
ret.push_back(v.back());
|
||||
ret.emplace_back(v.front());
|
||||
ret.emplace_back(v.back());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -545,11 +545,11 @@ std::vector<Vec2> AutoPolygon::expand(const std::vector<Vec2>& points, const axi
|
|||
cl.AddPath(p->Contour, ClipperLib::ptSubject, true);
|
||||
// create the clipping rect
|
||||
ClipperLib::Path clamp;
|
||||
clamp.push_back(ClipperLib::IntPoint(0, 0));
|
||||
clamp.push_back(ClipperLib::IntPoint(static_cast<ClipperLib::cInt>(rect.size.width / _scaleFactor * PRECISION), 0));
|
||||
clamp.push_back(ClipperLib::IntPoint(static_cast<ClipperLib::cInt>(rect.size.width / _scaleFactor * PRECISION),
|
||||
clamp.emplace_back(ClipperLib::IntPoint(0, 0));
|
||||
clamp.emplace_back(ClipperLib::IntPoint(static_cast<ClipperLib::cInt>(rect.size.width / _scaleFactor * PRECISION), 0));
|
||||
clamp.emplace_back(ClipperLib::IntPoint(static_cast<ClipperLib::cInt>(rect.size.width / _scaleFactor * PRECISION),
|
||||
static_cast<ClipperLib::cInt>(rect.size.height / _scaleFactor * PRECISION)));
|
||||
clamp.push_back(
|
||||
clamp.emplace_back(
|
||||
ClipperLib::IntPoint(0, static_cast<ClipperLib::cInt>(rect.size.height / _scaleFactor * PRECISION)));
|
||||
cl.AddPath(clamp, ClipperLib::ptClip, true);
|
||||
cl.Execute(ClipperLib::ctIntersection, out);
|
||||
|
@ -562,7 +562,7 @@ std::vector<Vec2> AutoPolygon::expand(const std::vector<Vec2>& points, const axi
|
|||
}
|
||||
for (const auto& pt : p2->Contour)
|
||||
{
|
||||
outPoints.push_back(Vec2(pt.X / PRECISION, pt.Y / PRECISION));
|
||||
outPoints.emplace_back(Vec2(pt.X / PRECISION, pt.Y / PRECISION));
|
||||
}
|
||||
return outPoints;
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& po
|
|||
for (const auto& pt : points)
|
||||
{
|
||||
p2t::Point* p = new p2t::Point(pt.x, pt.y);
|
||||
p2points.push_back(p);
|
||||
p2points.emplace_back(p);
|
||||
}
|
||||
p2t::CDT cdt(p2points);
|
||||
cdt.Triangulate();
|
||||
|
@ -612,7 +612,7 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& po
|
|||
if (found)
|
||||
{
|
||||
// if we found the same vertex, don't add to verts, but use the same vertex with indices
|
||||
indices.push_back(j);
|
||||
indices.emplace_back(j);
|
||||
idx++;
|
||||
}
|
||||
else
|
||||
|
@ -621,8 +621,8 @@ TrianglesCommand::Triangles AutoPolygon::triangulate(const std::vector<Vec2>& po
|
|||
auto c4b = Color4B::WHITE;
|
||||
auto t2f = Tex2F(0, 0); // don't worry about tex coords now, we calculate that later
|
||||
V3F_C4B_T2F vert = {v3, c4b, t2f};
|
||||
verts.push_back(vert);
|
||||
indices.push_back(vdx);
|
||||
verts.emplace_back(vert);
|
||||
indices.emplace_back(vdx);
|
||||
idx++;
|
||||
vdx++;
|
||||
}
|
||||
|
|
|
@ -504,7 +504,7 @@ void Camera::setScene(Scene* scene)
|
|||
auto it = std::find(cameras.begin(), cameras.end(), this);
|
||||
if (it == cameras.end())
|
||||
{
|
||||
_scene->_cameras.push_back(this);
|
||||
_scene->_cameras.emplace_back(this);
|
||||
// notify scene that the camera order is dirty
|
||||
_scene->setCameraOrderDirty();
|
||||
}
|
||||
|
|
|
@ -369,7 +369,7 @@ void FastTMXLayer::setupTiles()
|
|||
{
|
||||
if (_tileSet->_animationInfo.find(gid) != _tileSet->_animationInfo.end())
|
||||
{
|
||||
_animTileCoord[gid].push_back(Vec2(newX, y));
|
||||
_animTileCoord[gid].emplace_back(Vec2(newX, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,13 +44,13 @@ void Label::computeAlignmentOffset()
|
|||
case axis::TextHAlignment::CENTER:
|
||||
for (auto&& lineWidth : _linesWidth)
|
||||
{
|
||||
_linesOffsetX.push_back((_contentSize.width - lineWidth) / 2.f);
|
||||
_linesOffsetX.emplace_back((_contentSize.width - lineWidth) / 2.f);
|
||||
}
|
||||
break;
|
||||
case axis::TextHAlignment::RIGHT:
|
||||
for (auto&& lineWidth : _linesWidth)
|
||||
{
|
||||
_linesOffsetX.push_back(_contentSize.width - lineWidth);
|
||||
_linesOffsetX.emplace_back(_contentSize.width - lineWidth);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -174,7 +174,7 @@ bool Label::multilineTextWrap(const std::function<int(const std::u32string&, int
|
|||
char32_t character = _utf32Text[index];
|
||||
if (character == StringUtils::UnicodeCharacters::NewLine)
|
||||
{
|
||||
_linesWidth.push_back(letterRight);
|
||||
_linesWidth.emplace_back(letterRight);
|
||||
letterRight = 0.f;
|
||||
lineIndex++;
|
||||
nextTokenX = 0.f;
|
||||
|
@ -222,7 +222,7 @@ bool Label::multilineTextWrap(const std::function<int(const std::u32string&, int
|
|||
letterX + letterDef.width * _bmfontScale > _maxLineWidth && !StringUtils::isUnicodeSpace(character) &&
|
||||
nextChangeSize)
|
||||
{
|
||||
_linesWidth.push_back(letterRight - whitespaceWidth);
|
||||
_linesWidth.emplace_back(letterRight - whitespaceWidth);
|
||||
nextWhitespaceWidth = 0.f;
|
||||
letterRight = 0.f;
|
||||
lineIndex++;
|
||||
|
@ -282,12 +282,12 @@ bool Label::multilineTextWrap(const std::function<int(const std::u32string&, int
|
|||
|
||||
if (_linesWidth.empty())
|
||||
{
|
||||
_linesWidth.push_back(letterRight);
|
||||
_linesWidth.emplace_back(letterRight);
|
||||
longestLine = letterRight;
|
||||
}
|
||||
else
|
||||
{
|
||||
_linesWidth.push_back(letterRight - nextWhitespaceWidth);
|
||||
_linesWidth.emplace_back(letterRight - nextWhitespaceWidth);
|
||||
for (auto&& lineWidth : _linesWidth)
|
||||
{
|
||||
if (longestLine < lineWidth)
|
||||
|
@ -426,7 +426,7 @@ void Label::recordLetterInfo(const axis::Vec2& point, char32_t utf32Char, int le
|
|||
if (static_cast<std::size_t>(letterIndex) >= _lettersInfo.size())
|
||||
{
|
||||
LetterInfo tmpInfo;
|
||||
_lettersInfo.push_back(tmpInfo);
|
||||
_lettersInfo.emplace_back(tmpInfo);
|
||||
}
|
||||
_lettersInfo[letterIndex].lineIndex = lineIndex;
|
||||
_lettersInfo[letterIndex].utf32Char = utf32Char;
|
||||
|
@ -441,7 +441,7 @@ void Label::recordPlaceholderInfo(int letterIndex, char32_t utf32Char)
|
|||
if (static_cast<std::size_t>(letterIndex) >= _lettersInfo.size())
|
||||
{
|
||||
LetterInfo tmpInfo;
|
||||
_lettersInfo.push_back(tmpInfo);
|
||||
_lettersInfo.emplace_back(tmpInfo);
|
||||
}
|
||||
_lettersInfo[letterIndex].utf32Char = utf32Char;
|
||||
_lettersInfo[letterIndex].valid = false;
|
||||
|
|
|
@ -41,7 +41,7 @@ void BaseLight::onEnter()
|
|||
auto& lights = scene->_lights;
|
||||
auto iter = std::find(lights.begin(), lights.end(), this);
|
||||
if (iter == lights.end())
|
||||
lights.push_back(this);
|
||||
lights.emplace_back(this);
|
||||
}
|
||||
Node::onEnter();
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ void Menu::alignItemsInColumns(int columns, va_list args)
|
|||
ValueVector rows;
|
||||
while (columns)
|
||||
{
|
||||
rows.push_back(Value(columns));
|
||||
rows.emplace_back(Value(columns));
|
||||
columns = va_arg(args, int);
|
||||
}
|
||||
alignItemsInColumnsWithArray(rows);
|
||||
|
@ -439,7 +439,7 @@ void Menu::alignItemsInRows(int rows, va_list args)
|
|||
ValueVector array;
|
||||
while (rows)
|
||||
{
|
||||
array.push_back(Value(rows));
|
||||
array.emplace_back(Value(rows));
|
||||
rows = va_arg(args, int);
|
||||
}
|
||||
alignItemsInRowsWithArray(array);
|
||||
|
@ -475,8 +475,8 @@ void Menu::alignItemsInRowsWithArray(const ValueVector& columns)
|
|||
|
||||
if (rowsOccupied >= columnRows)
|
||||
{
|
||||
columnWidths.push_back(columnWidth);
|
||||
columnHeights.push_back(columnHeight);
|
||||
columnWidths.emplace_back(columnWidth);
|
||||
columnHeights.emplace_back(columnHeight);
|
||||
width += columnWidth + 10;
|
||||
|
||||
rowsOccupied = 0;
|
||||
|
|
|
@ -1367,7 +1367,7 @@ void ParticleSystem::setMultiAnimationRandom()
|
|||
{
|
||||
_randomAnimations.clear();
|
||||
for (auto&& a : _animations)
|
||||
_randomAnimations.push_back(a.first);
|
||||
_randomAnimations.emplace_back(a.first);
|
||||
}
|
||||
|
||||
void ParticleSystem::setAnimationIndicesAtlas()
|
||||
|
|
|
@ -264,7 +264,7 @@ void PlistSpriteSheetLoader::addSpriteFramesWithDictionary(ValueMap& dictionary,
|
|||
auto oneAlias = value.asString();
|
||||
if (std::find(frameAliases.begin(), frameAliases.end(), oneAlias) == frameAliases.end())
|
||||
{
|
||||
frameAliases.push_back(std::move(oneAlias));
|
||||
frameAliases.emplace_back(std::move(oneAlias));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -462,7 +462,7 @@ void PlistSpriteSheetLoader::reloadSpriteFramesWithDictionary(ValueMap& dict,
|
|||
auto oneAlias = value.asString();
|
||||
if (std::find(frameAliases.begin(), frameAliases.end(), oneAlias) == frameAliases.end())
|
||||
{
|
||||
frameAliases.push_back(std::move(oneAlias));
|
||||
frameAliases.emplace_back(std::move(oneAlias));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -614,7 +614,7 @@ void SpriteBatchNode::appendChild(Sprite* sprite)
|
|||
increaseAtlasCapacity();
|
||||
}
|
||||
|
||||
_descendants.push_back(sprite);
|
||||
_descendants.emplace_back(sprite);
|
||||
int index = static_cast<int>(_descendants.size() - 1);
|
||||
|
||||
sprite->setAtlasIndex(index);
|
||||
|
|
|
@ -156,7 +156,7 @@ void SpriteFrameCache::removeUnusedSpriteFrames()
|
|||
auto* spriteFrame = iter.second;
|
||||
if (spriteFrame->getReferenceCount() == 1)
|
||||
{
|
||||
toRemoveFrames.push_back(iter.first);
|
||||
toRemoveFrames.emplace_back(iter.first);
|
||||
spriteFrame->getTexture()->removeSpriteFrameCapInset(spriteFrame);
|
||||
AXLOG("cocos2d: SpriteFrameCache: removing unused frame: %s", iter.first.c_str());
|
||||
removed = true;
|
||||
|
@ -217,7 +217,7 @@ void SpriteFrameCache::removeSpriteFramesFromDictionary(ValueMap& dictionary)
|
|||
{
|
||||
if (findFrame(iter.first))
|
||||
{
|
||||
keysToRemove.push_back(iter.first);
|
||||
keysToRemove.emplace_back(iter.first);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ void SpriteFrameCache::removeSpriteFramesFromTexture(Texture2D* texture)
|
|||
auto* frame = findFrame(key);
|
||||
if (frame && (frame->getTexture() == texture))
|
||||
{
|
||||
keysToRemove.push_back(key);
|
||||
keysToRemove.emplace_back(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -516,7 +516,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char* name, const char** atts
|
|||
dict["rotation"] = attributeDict["rotation"].asDouble();
|
||||
|
||||
// Add the object to the objectGroup
|
||||
objectGroup->getObjects().push_back(Value(dict));
|
||||
objectGroup->getObjects().emplace_back(Value(dict));
|
||||
|
||||
// The parent element is now "object"
|
||||
tmxMapInfo->setParentElement(TMXPropertyObject);
|
||||
|
@ -608,7 +608,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char* name, const char** atts
|
|||
}
|
||||
|
||||
// add to points array
|
||||
pointsArray.push_back(Value(pointDict));
|
||||
pointsArray.emplace_back(Value(pointDict));
|
||||
}
|
||||
|
||||
dict["points"] = Value(pointsArray);
|
||||
|
@ -653,7 +653,7 @@ void TMXMapInfo::startElement(void* /*ctx*/, const char* name, const char** atts
|
|||
}
|
||||
|
||||
// add to points array
|
||||
pointsArray.push_back(Value(pointDict));
|
||||
pointsArray.emplace_back(Value(pointDict));
|
||||
}
|
||||
|
||||
dict["polylinePoints"] = Value(pointsArray);
|
||||
|
@ -745,7 +745,7 @@ void TMXMapInfo::endElement(void* /*ctx*/, const char* name)
|
|||
istringstream rowstr(sRow);
|
||||
while (getline(rowstr, sGID, ','))
|
||||
{
|
||||
gidTokens.push_back(sGID);
|
||||
gidTokens.emplace_back(sGID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ void Animate3D::update(float t)
|
|||
eventInfo->target = _target;
|
||||
eventInfo->frame = keyFrame.first;
|
||||
eventInfo->userInfo = &_keyFrameUserInfos[keyFrame.first];
|
||||
eventInfos.push_back(eventInfo);
|
||||
eventInfos.emplace_back(eventInfo);
|
||||
frameEvent->setUserData((void*)eventInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,10 +117,10 @@ bool Animation3D::init(const Animation3DData& data)
|
|||
std::vector<float> values;
|
||||
for (const auto& keyIter : iter.second)
|
||||
{
|
||||
keys.push_back(keyIter._time);
|
||||
values.push_back(keyIter._key.x);
|
||||
values.push_back(keyIter._key.y);
|
||||
values.push_back(keyIter._key.z);
|
||||
keys.emplace_back(keyIter._time);
|
||||
values.emplace_back(keyIter._key.x);
|
||||
values.emplace_back(keyIter._key.y);
|
||||
values.emplace_back(keyIter._key.z);
|
||||
}
|
||||
|
||||
curve->translateCurve = Curve::AnimationCurveVec3::create(&keys[0], &values[0], (int)keys.size());
|
||||
|
@ -143,11 +143,11 @@ bool Animation3D::init(const Animation3DData& data)
|
|||
std::vector<float> values;
|
||||
for (const auto& keyIter : iter.second)
|
||||
{
|
||||
keys.push_back(keyIter._time);
|
||||
values.push_back(keyIter._key.x);
|
||||
values.push_back(keyIter._key.y);
|
||||
values.push_back(keyIter._key.z);
|
||||
values.push_back(keyIter._key.w);
|
||||
keys.emplace_back(keyIter._time);
|
||||
values.emplace_back(keyIter._key.x);
|
||||
values.emplace_back(keyIter._key.y);
|
||||
values.emplace_back(keyIter._key.z);
|
||||
values.emplace_back(keyIter._key.w);
|
||||
}
|
||||
|
||||
curve->rotCurve = Curve::AnimationCurveQuat::create(&keys[0], &values[0], (int)keys.size());
|
||||
|
@ -170,10 +170,10 @@ bool Animation3D::init(const Animation3DData& data)
|
|||
std::vector<float> values;
|
||||
for (const auto& keyIter : iter.second)
|
||||
{
|
||||
keys.push_back(keyIter._time);
|
||||
values.push_back(keyIter._key.x);
|
||||
values.push_back(keyIter._key.y);
|
||||
values.push_back(keyIter._key.z);
|
||||
keys.emplace_back(keyIter._time);
|
||||
values.emplace_back(keyIter._key.x);
|
||||
values.emplace_back(keyIter._key.y);
|
||||
values.emplace_back(keyIter._key.z);
|
||||
}
|
||||
|
||||
curve->scaleCurve = Curve::AnimationCurveVec3::create(&keys[0], &values[0], (int)keys.size());
|
||||
|
|
|
@ -110,7 +110,7 @@ void getChildMap(std::map<int, std::vector<int>>& map, SkinData* skinData, const
|
|||
if (parent_name_index < 0)
|
||||
{
|
||||
skinData->addNodeBoneNames(parent_name);
|
||||
skinData->nodeBoneOriginMatrices.push_back(transform);
|
||||
skinData->nodeBoneOriginMatrices.emplace_back(transform);
|
||||
parent_name_index = skinData->getBoneNameIndex(parent_name);
|
||||
}
|
||||
else if (parent_name_index < static_cast<int>(skinData->skinBoneNames.size()))
|
||||
|
@ -139,7 +139,7 @@ void getChildMap(std::map<int, std::vector<int>>& map, SkinData* skinData, const
|
|||
child_name_index = skinData->getBoneNameIndex(child_name);
|
||||
}
|
||||
|
||||
map[parent_name_index].push_back(child_name_index);
|
||||
map[parent_name_index].emplace_back(child_name_index);
|
||||
|
||||
getChildMap(map, skinData, child);
|
||||
}
|
||||
|
@ -241,10 +241,10 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas,
|
|||
tex.wrapT = backend::SamplerAddressMode::CLAMP_TO_EDGE;
|
||||
|
||||
sprintf(str, "%d", ++i);
|
||||
materialdata.textures.push_back(tex);
|
||||
materialdata.textures.emplace_back(tex);
|
||||
materialdata.id = str;
|
||||
material.name = str;
|
||||
materialdatas.materials.push_back(materialdata);
|
||||
materialdatas.materials.emplace_back(materialdata);
|
||||
}
|
||||
|
||||
// convert mesh
|
||||
|
@ -259,41 +259,41 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas,
|
|||
if (mesh.positions.size())
|
||||
{
|
||||
attrib.vertexAttrib = shaderinfos::VertexKey::VERTEX_ATTRIB_POSITION;
|
||||
meshdata->attribs.push_back(attrib);
|
||||
meshdata->attribs.emplace_back(attrib);
|
||||
}
|
||||
bool hasnormal = false, hastex = false;
|
||||
if (mesh.normals.size())
|
||||
{
|
||||
hasnormal = true;
|
||||
attrib.vertexAttrib = shaderinfos::VertexKey::VERTEX_ATTRIB_NORMAL;
|
||||
meshdata->attribs.push_back(attrib);
|
||||
meshdata->attribs.emplace_back(attrib);
|
||||
}
|
||||
if (mesh.texcoords.size())
|
||||
{
|
||||
hastex = true;
|
||||
attrib.type = parseGLDataType("GL_FLOAT", 2);
|
||||
attrib.vertexAttrib = shaderinfos::VertexKey::VERTEX_ATTRIB_TEX_COORD;
|
||||
meshdata->attribs.push_back(attrib);
|
||||
meshdata->attribs.emplace_back(attrib);
|
||||
}
|
||||
|
||||
auto vertexNum = mesh.positions.size() / 3;
|
||||
for (unsigned int k = 0; k < vertexNum; ++k)
|
||||
{
|
||||
meshdata->vertex.push_back(mesh.positions[k * 3]);
|
||||
meshdata->vertex.push_back(mesh.positions[k * 3 + 1]);
|
||||
meshdata->vertex.push_back(mesh.positions[k * 3 + 2]);
|
||||
meshdata->vertex.emplace_back(mesh.positions[k * 3]);
|
||||
meshdata->vertex.emplace_back(mesh.positions[k * 3 + 1]);
|
||||
meshdata->vertex.emplace_back(mesh.positions[k * 3 + 2]);
|
||||
|
||||
if (hasnormal)
|
||||
{
|
||||
meshdata->vertex.push_back(mesh.normals[k * 3]);
|
||||
meshdata->vertex.push_back(mesh.normals[k * 3 + 1]);
|
||||
meshdata->vertex.push_back(mesh.normals[k * 3 + 2]);
|
||||
meshdata->vertex.emplace_back(mesh.normals[k * 3]);
|
||||
meshdata->vertex.emplace_back(mesh.normals[k * 3 + 1]);
|
||||
meshdata->vertex.emplace_back(mesh.normals[k * 3 + 2]);
|
||||
}
|
||||
|
||||
if (hastex)
|
||||
{
|
||||
meshdata->vertex.push_back(mesh.texcoords[k * 2]);
|
||||
meshdata->vertex.push_back(mesh.texcoords[k * 2 + 1]);
|
||||
meshdata->vertex.emplace_back(mesh.texcoords[k * 2]);
|
||||
meshdata->vertex.emplace_back(mesh.texcoords[k * 2 + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,9 +303,9 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas,
|
|||
{
|
||||
int id = mesh.material_ids[k];
|
||||
size_t idx = k * 3;
|
||||
subMeshMap[id].push_back(mesh.indices[idx]);
|
||||
subMeshMap[id].push_back(mesh.indices[idx + 1]);
|
||||
subMeshMap[id].push_back(mesh.indices[idx + 2]);
|
||||
subMeshMap[id].emplace_back(mesh.indices[idx]);
|
||||
subMeshMap[id].emplace_back(mesh.indices[idx + 1]);
|
||||
subMeshMap[id].emplace_back(mesh.indices[idx + 2]);
|
||||
}
|
||||
|
||||
auto node = new NodeData();
|
||||
|
@ -313,18 +313,18 @@ bool Bundle3D::loadObj(MeshDatas& meshdatas,
|
|||
for (auto&& submesh : subMeshMap)
|
||||
{
|
||||
auto& storedIndices = meshdata->subMeshIndices.emplace_back(std::move(submesh.second));
|
||||
meshdata->subMeshAABB.push_back(
|
||||
meshdata->subMeshAABB.emplace_back(
|
||||
calculateAABB(meshdata->vertex, meshdata->getPerVertexSize(), storedIndices));
|
||||
sprintf(str, "%d", ++i);
|
||||
meshdata->subMeshIds.push_back(str);
|
||||
meshdata->subMeshIds.emplace_back(str);
|
||||
|
||||
auto modelnode = new ModelData();
|
||||
modelnode->materialId = submesh.first == -1 ? "" : materials[submesh.first].name;
|
||||
modelnode->subMeshId = str;
|
||||
node->modelNodeDatas.push_back(modelnode);
|
||||
node->modelNodeDatas.emplace_back(modelnode);
|
||||
}
|
||||
nodedatas.nodes.push_back(node);
|
||||
meshdatas.meshDatas.push_back(meshdata);
|
||||
nodedatas.nodes.emplace_back(node);
|
||||
meshdatas.meshDatas.emplace_back(meshdata);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -449,7 +449,7 @@ bool Bundle3D::loadMeshDatasBinary(MeshDatas& meshdatas)
|
|||
{
|
||||
IndexArray indexArray{};
|
||||
std::string meshPartid = _binaryReader.readString();
|
||||
meshData->subMeshIds.push_back(meshPartid);
|
||||
meshData->subMeshIds.emplace_back(meshPartid);
|
||||
unsigned int nIndexCount;
|
||||
if (_binaryReader.read(&nIndexCount, 4, 1) != 1)
|
||||
{
|
||||
|
@ -464,7 +464,7 @@ bool Bundle3D::loadMeshDatasBinary(MeshDatas& meshdatas)
|
|||
}
|
||||
auto& storedIndices = meshData->subMeshIndices.emplace_back(std::move(indexArray));
|
||||
meshData->numIndex = (int)meshData->subMeshIndices.size();
|
||||
// meshData->subMeshAABB.push_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(),
|
||||
// meshData->subMeshAABB.emplace_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(),
|
||||
// indexArray));
|
||||
if (_version != "0.3" && _version != "0.4" && _version != "0.5")
|
||||
{
|
||||
|
@ -475,15 +475,15 @@ bool Bundle3D::loadMeshDatasBinary(MeshDatas& meshdatas)
|
|||
AXLOG("warning: Failed to read meshdata: aabb '%s'.", _path.c_str());
|
||||
goto FAILED;
|
||||
}
|
||||
meshData->subMeshAABB.push_back(AABB(Vec3(aabb[0], aabb[1], aabb[2]), Vec3(aabb[3], aabb[4], aabb[5])));
|
||||
meshData->subMeshAABB.emplace_back(AABB(Vec3(aabb[0], aabb[1], aabb[2]), Vec3(aabb[3], aabb[4], aabb[5])));
|
||||
}
|
||||
else
|
||||
{
|
||||
meshData->subMeshAABB.push_back(
|
||||
meshData->subMeshAABB.emplace_back(
|
||||
calculateAABB(meshData->vertex, meshData->getPerVertexSize(), storedIndices));
|
||||
}
|
||||
}
|
||||
meshdatas.meshDatas.push_back(meshData);
|
||||
meshdatas.meshDatas.emplace_back(meshData);
|
||||
}
|
||||
return true;
|
||||
|
||||
|
@ -568,7 +568,7 @@ bool Bundle3D::loadMeshDatasBinary_0_1(MeshDatas& meshdatas)
|
|||
}
|
||||
meshVertexAttribute.vertexAttrib = usage;
|
||||
|
||||
meshdata->attribs.push_back(meshVertexAttribute);
|
||||
meshdata->attribs.emplace_back(meshVertexAttribute);
|
||||
}
|
||||
|
||||
// Read vertex data
|
||||
|
@ -609,10 +609,10 @@ bool Bundle3D::loadMeshDatasBinary_0_1(MeshDatas& meshdatas)
|
|||
}
|
||||
|
||||
auto& storedIndices = meshdata->subMeshIndices.emplace_back(std::move(indices));
|
||||
meshdata->subMeshAABB.push_back(calculateAABB(meshdata->vertex, meshdata->getPerVertexSize(), storedIndices));
|
||||
meshdata->subMeshAABB.emplace_back(calculateAABB(meshdata->vertex, meshdata->getPerVertexSize(), storedIndices));
|
||||
}
|
||||
|
||||
meshdatas.meshDatas.push_back(meshdata);
|
||||
meshdatas.meshDatas.emplace_back(meshdata);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -682,7 +682,7 @@ bool Bundle3D::loadMeshDatasBinary_0_2(MeshDatas& meshdatas)
|
|||
}
|
||||
meshVertexAttribute.vertexAttrib = usage;
|
||||
|
||||
meshdata->attribs.push_back(meshVertexAttribute);
|
||||
meshdata->attribs.emplace_back(meshVertexAttribute);
|
||||
}
|
||||
|
||||
// Read vertex data
|
||||
|
@ -730,10 +730,10 @@ bool Bundle3D::loadMeshDatasBinary_0_2(MeshDatas& meshdatas)
|
|||
}
|
||||
|
||||
auto& storedIndices = meshdata->subMeshIndices.emplace_back(std::move(indices));
|
||||
meshdata->subMeshAABB.push_back(calculateAABB(meshdata->vertex, meshdata->getPerVertexSize(), storedIndices));
|
||||
meshdata->subMeshAABB.emplace_back(calculateAABB(meshdata->vertex, meshdata->getPerVertexSize(), storedIndices));
|
||||
}
|
||||
|
||||
meshdatas.meshDatas.push_back(meshdata);
|
||||
meshdatas.meshDatas.emplace_back(meshdata);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -770,7 +770,7 @@ bool Bundle3D::loadMeshDatasJson(MeshDatas& meshdatas)
|
|||
meshData->vertexSizeInFloat = mesh_data_vertex_array_size;
|
||||
for (rapidjson::SizeType i = 0; i < mesh_data_vertex_array_size; ++i)
|
||||
{
|
||||
meshData->vertex.push_back(mesh_data_vertex_array[i].GetFloat());
|
||||
meshData->vertex.emplace_back(mesh_data_vertex_array[i].GetFloat());
|
||||
}
|
||||
// mesh part
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -779,12 +779,12 @@ bool Bundle3D::loadMeshDatasJson(MeshDatas& meshdatas)
|
|||
{
|
||||
IndexArray indexArray{};
|
||||
const rapidjson::Value& mesh_part = mesh_part_array[i];
|
||||
meshData->subMeshIds.push_back(mesh_part[ID].GetString());
|
||||
meshData->subMeshIds.emplace_back(mesh_part[ID].GetString());
|
||||
// index_number
|
||||
const rapidjson::Value& indices_val_array = mesh_part[INDICES];
|
||||
for (rapidjson::SizeType j = 0, indices_val_array_size = indices_val_array.Size();
|
||||
j < indices_val_array_size; ++j)
|
||||
indexArray.push_back((unsigned short)indices_val_array[j].GetUint());
|
||||
indexArray.emplace_back((unsigned short)indices_val_array[j].GetUint());
|
||||
|
||||
auto& storedIndices = meshData->subMeshIndices.emplace_back(std::move(indexArray));
|
||||
meshData->numIndex = (int)meshData->subMeshIndices.size();
|
||||
|
@ -800,20 +800,20 @@ bool Bundle3D::loadMeshDatasJson(MeshDatas& meshdatas)
|
|||
Vec3 max(mesh_part_aabb[(rapidjson::SizeType)3].GetFloat(),
|
||||
mesh_part_aabb[(rapidjson::SizeType)4].GetFloat(),
|
||||
mesh_part_aabb[(rapidjson::SizeType)5].GetFloat());
|
||||
meshData->subMeshAABB.push_back(AABB(min, max));
|
||||
meshData->subMeshAABB.emplace_back(AABB(min, max));
|
||||
}
|
||||
else
|
||||
{
|
||||
meshData->subMeshAABB.push_back(
|
||||
meshData->subMeshAABB.emplace_back(
|
||||
calculateAABB(meshData->vertex, meshData->getPerVertexSize(), storedIndices));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
meshData->subMeshAABB.push_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(), storedIndices));
|
||||
meshData->subMeshAABB.emplace_back(calculateAABB(meshData->vertex, meshData->getPerVertexSize(), storedIndices));
|
||||
}
|
||||
}
|
||||
meshdatas.meshDatas.push_back(meshData);
|
||||
meshdatas.meshDatas.emplace_back(meshData);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -828,8 +828,8 @@ bool Bundle3D::loadNodes(NodeDatas& nodedatas)
|
|||
auto modelnode = new ModelData();
|
||||
modelnode->materialId = "";
|
||||
modelnode->subMeshId = "";
|
||||
node->modelNodeDatas.push_back(modelnode);
|
||||
nodedatas.nodes.push_back(node);
|
||||
node->modelNodeDatas.emplace_back(modelnode);
|
||||
nodedatas.nodes.emplace_back(node);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -858,18 +858,18 @@ bool Bundle3D::loadNodes(NodeDatas& nodedatas)
|
|||
auto parent = nodeDatas[it.first];
|
||||
for (const auto& child : children)
|
||||
{
|
||||
parent->children.push_back(nodeDatas[child]);
|
||||
parent->children.emplace_back(nodeDatas[child]);
|
||||
}
|
||||
}
|
||||
nodedatas.skeleton.push_back(nodeDatas[skinData.rootBoneIndex]);
|
||||
nodedatas.skeleton.emplace_back(nodeDatas[skinData.rootBoneIndex]);
|
||||
auto node = new NodeData();
|
||||
auto modelnode = new ModelData();
|
||||
modelnode->materialId = "";
|
||||
modelnode->subMeshId = "";
|
||||
modelnode->bones = skinData.skinBoneNames;
|
||||
modelnode->invBindPose = skinData.inverseBindPoseMatrices;
|
||||
node->modelNodeDatas.push_back(modelnode);
|
||||
nodedatas.nodes.push_back(node);
|
||||
node->modelNodeDatas.emplace_back(modelnode);
|
||||
nodedatas.nodes.emplace_back(node);
|
||||
delete[] nodeDatas;
|
||||
}
|
||||
else
|
||||
|
@ -959,9 +959,9 @@ bool Bundle3D::loadMaterialsBinary(MaterialDatas& materialdatas)
|
|||
textureData.type = parseGLTextureType(_binaryReader.readString());
|
||||
textureData.wrapS = parseSamplerAddressMode(_binaryReader.readString());
|
||||
textureData.wrapT = parseSamplerAddressMode(_binaryReader.readString());
|
||||
materialData.textures.push_back(textureData);
|
||||
materialData.textures.emplace_back(textureData);
|
||||
}
|
||||
materialdatas.materials.push_back(materialData);
|
||||
materialdatas.materials.emplace_back(materialData);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -983,8 +983,8 @@ bool Bundle3D::loadMaterialsBinary_0_1(MaterialDatas& materialdatas)
|
|||
textureData.filename = texturePath.empty() ? texturePath : _modelPath + texturePath;
|
||||
textureData.type = NTextureData::Usage::Diffuse;
|
||||
textureData.id = "";
|
||||
materialData.textures.push_back(textureData);
|
||||
materialdatas.materials.push_back(materialData);
|
||||
materialData.textures.emplace_back(textureData);
|
||||
materialdatas.materials.emplace_back(materialData);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1011,8 +1011,8 @@ bool Bundle3D::loadMaterialsBinary_0_2(MaterialDatas& materialdatas)
|
|||
textureData.filename = texturePath.empty() ? texturePath : _modelPath + texturePath;
|
||||
textureData.type = NTextureData::Usage::Diffuse;
|
||||
textureData.id = "";
|
||||
materialData.textures.push_back(textureData);
|
||||
materialdatas.materials.push_back(materialData);
|
||||
materialData.textures.emplace_back(textureData);
|
||||
materialdatas.materials.emplace_back(materialData);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1054,10 +1054,10 @@ bool Bundle3D::loadMaterialsJson(MaterialDatas& materialdatas)
|
|||
textureData.type = parseGLTextureType(texture_val["type"].GetString());
|
||||
textureData.wrapS = parseSamplerAddressMode(texture_val["wrapModeU"].GetString());
|
||||
textureData.wrapT = parseSamplerAddressMode(texture_val["wrapModeV"].GetString());
|
||||
materialData.textures.push_back(textureData);
|
||||
materialData.textures.emplace_back(textureData);
|
||||
}
|
||||
}
|
||||
materialdatas.materials.push_back(materialData);
|
||||
materialdatas.materials.emplace_back(materialData);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1192,8 +1192,8 @@ bool Bundle3D::loadMeshDataJson_0_1(MeshDatas& meshdatas)
|
|||
indices.at<uint16_t>(i) = (unsigned short)indices_val_array[i].GetUint();
|
||||
|
||||
auto& storedIndices = meshdata->subMeshIndices.emplace_back(std::move(indices));
|
||||
meshdata->subMeshAABB.push_back(calculateAABB(meshdata->vertex, meshdata->getPerVertexSize(), storedIndices));
|
||||
meshdatas.meshDatas.push_back(meshdata);
|
||||
meshdata->subMeshAABB.emplace_back(calculateAABB(meshdata->vertex, meshdata->getPerVertexSize(), storedIndices));
|
||||
meshdatas.meshDatas.emplace_back(meshdata);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1246,9 +1246,9 @@ bool Bundle3D::loadMeshDataJson_0_2(MeshDatas& meshdatas)
|
|||
indices.at<uint16_t>(j) = (unsigned short)indices_val_array[j].GetUint();
|
||||
|
||||
auto& storedIndices = meshdata->subMeshIndices.emplace_back(std::move(indices));
|
||||
meshdata->subMeshAABB.push_back(calculateAABB(meshdata->vertex, meshdata->getPerVertexSize(), storedIndices));
|
||||
meshdata->subMeshAABB.emplace_back(calculateAABB(meshdata->vertex, meshdata->getPerVertexSize(), storedIndices));
|
||||
}
|
||||
meshdatas.meshDatas.push_back(meshdata);
|
||||
meshdatas.meshDatas.emplace_back(meshdata);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1278,7 @@ bool Bundle3D::loadSkinDataJson(SkinData* skindata)
|
|||
{
|
||||
mat_bind_pos.m[j] = bind_pos[j].GetFloat();
|
||||
}
|
||||
skindata->inverseBindPoseMatrices.push_back(mat_bind_pos);
|
||||
skindata->inverseBindPoseMatrices.emplace_back(mat_bind_pos);
|
||||
}
|
||||
|
||||
// set root bone information
|
||||
|
@ -1322,13 +1322,13 @@ bool Bundle3D::loadSkinDataBinary(SkinData* skindata)
|
|||
for (unsigned int i = 0; i < boneNum; ++i)
|
||||
{
|
||||
std::string skinBoneName = _binaryReader.readString();
|
||||
skindata->skinBoneNames.push_back(skinBoneName);
|
||||
skindata->skinBoneNames.emplace_back(skinBoneName);
|
||||
if (!_binaryReader.readMatrix(bindpos))
|
||||
{
|
||||
AXLOG("warning: Failed to load SkinData: bindpos '%s'.", _path.c_str());
|
||||
return false;
|
||||
}
|
||||
skindata->inverseBindPoseMatrices.push_back(bindpos);
|
||||
skindata->inverseBindPoseMatrices.emplace_back(bindpos);
|
||||
}
|
||||
|
||||
skindata->skinBoneOriginMatrices.resize(boneNum);
|
||||
|
@ -1342,7 +1342,7 @@ bool Bundle3D::loadSkinDataBinary(SkinData* skindata)
|
|||
{
|
||||
skindata->addNodeBoneNames(boneName);
|
||||
rootIndex = skindata->getBoneNameIndex(boneName);
|
||||
skindata->nodeBoneOriginMatrices.push_back(bindShape);
|
||||
skindata->nodeBoneOriginMatrices.emplace_back(bindShape);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1373,7 +1373,7 @@ bool Bundle3D::loadSkinDataBinary(SkinData* skindata)
|
|||
{
|
||||
skindata->addNodeBoneNames(id);
|
||||
index = skindata->getBoneNameIndex(id);
|
||||
skindata->nodeBoneOriginMatrices.push_back(transform);
|
||||
skindata->nodeBoneOriginMatrices.emplace_back(transform);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1387,7 +1387,7 @@ bool Bundle3D::loadSkinDataBinary(SkinData* skindata)
|
|||
parentIndex = skindata->getBoneNameIndex(parentid);
|
||||
}
|
||||
|
||||
skindata->boneChild[parentIndex].push_back(index);
|
||||
skindata->boneChild[parentIndex].emplace_back(index);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1413,8 +1413,8 @@ bool Bundle3D::loadMaterialDataJson_0_1(MaterialDatas& materialdatas)
|
|||
textureData.filename = filename.empty() ? filename : _modelPath + filename;
|
||||
textureData.type = NTextureData::Usage::Diffuse;
|
||||
textureData.id = "";
|
||||
materialData.textures.push_back(textureData);
|
||||
materialdatas.materials.push_back(materialData);
|
||||
materialData.textures.emplace_back(textureData);
|
||||
materialdatas.materials.emplace_back(materialData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1438,9 +1438,9 @@ bool Bundle3D::loadMaterialDataJson_0_2(MaterialDatas& materialdatas)
|
|||
textureData.filename = filename.empty() ? filename : _modelPath + filename;
|
||||
textureData.type = NTextureData::Usage::Diffuse;
|
||||
textureData.id = "";
|
||||
materialData.textures.push_back(textureData);
|
||||
materialData.textures.emplace_back(textureData);
|
||||
}
|
||||
materialdatas.materials.push_back(materialData);
|
||||
materialdatas.materials.emplace_back(materialData);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1520,7 +1520,7 @@ bool Bundle3D::loadAnimationDataJson(std::string_view id, Animation3DData* anima
|
|||
float keytime = bone_keyframe[KEYTIME].GetFloat();
|
||||
Vec3 val(bone_keyframe_translation[(rapidjson::SizeType)0].GetFloat(),
|
||||
bone_keyframe_translation[1].GetFloat(), bone_keyframe_translation[2].GetFloat());
|
||||
animationdata->_translationKeys[bone_name].push_back(Animation3DData::Vec3Key(keytime, val));
|
||||
animationdata->_translationKeys[bone_name].emplace_back(Animation3DData::Vec3Key(keytime, val));
|
||||
}
|
||||
|
||||
if (bone_keyframe.HasMember(ROTATION))
|
||||
|
@ -1530,7 +1530,7 @@ bool Bundle3D::loadAnimationDataJson(std::string_view id, Animation3DData* anima
|
|||
Quaternion val = Quaternion(
|
||||
bone_keyframe_rotation[(rapidjson::SizeType)0].GetFloat(), bone_keyframe_rotation[1].GetFloat(),
|
||||
bone_keyframe_rotation[2].GetFloat(), bone_keyframe_rotation[3].GetFloat());
|
||||
animationdata->_rotationKeys[bone_name].push_back(Animation3DData::QuatKey(keytime, val));
|
||||
animationdata->_rotationKeys[bone_name].emplace_back(Animation3DData::QuatKey(keytime, val));
|
||||
}
|
||||
|
||||
if (bone_keyframe.HasMember(SCALE))
|
||||
|
@ -1539,7 +1539,7 @@ bool Bundle3D::loadAnimationDataJson(std::string_view id, Animation3DData* anima
|
|||
float keytime = bone_keyframe[KEYTIME].GetFloat();
|
||||
Vec3 val(bone_keyframe_scale[(rapidjson::SizeType)0].GetFloat(), bone_keyframe_scale[1].GetFloat(),
|
||||
bone_keyframe_scale[2].GetFloat());
|
||||
animationdata->_scaleKeys[bone_name].push_back(Animation3DData::Vec3Key(keytime, val));
|
||||
animationdata->_scaleKeys[bone_name].emplace_back(Animation3DData::Vec3Key(keytime, val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1642,7 +1642,7 @@ bool Bundle3D::loadAnimationDataBinary(std::string_view id, Animation3DData* ani
|
|||
AXLOG("warning: Failed to read AnimationData: rotate '%s'.", _path.c_str());
|
||||
return false;
|
||||
}
|
||||
animationdata->_rotationKeys[boneName].push_back(Animation3DData::QuatKey(keytime, rotate));
|
||||
animationdata->_rotationKeys[boneName].emplace_back(Animation3DData::QuatKey(keytime, rotate));
|
||||
}
|
||||
|
||||
// scale
|
||||
|
@ -1658,7 +1658,7 @@ bool Bundle3D::loadAnimationDataBinary(std::string_view id, Animation3DData* ani
|
|||
AXLOG("warning: Failed to read AnimationData: scale '%s'.", _path.c_str());
|
||||
return false;
|
||||
}
|
||||
animationdata->_scaleKeys[boneName].push_back(Animation3DData::Vec3Key(keytime, scale));
|
||||
animationdata->_scaleKeys[boneName].emplace_back(Animation3DData::Vec3Key(keytime, scale));
|
||||
}
|
||||
|
||||
// translation
|
||||
|
@ -1674,7 +1674,7 @@ bool Bundle3D::loadAnimationDataBinary(std::string_view id, Animation3DData* ani
|
|||
AXLOG("warning: Failed to read AnimationData: position '%s'.", _path.c_str());
|
||||
return false;
|
||||
}
|
||||
animationdata->_translationKeys[boneName].push_back(Animation3DData::Vec3Key(keytime, position));
|
||||
animationdata->_translationKeys[boneName].emplace_back(Animation3DData::Vec3Key(keytime, position));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1709,9 +1709,9 @@ bool Bundle3D::loadNodesJson(NodeDatas& nodedatas)
|
|||
|
||||
bool isSkeleton = jnode[SKELETON].GetBool();
|
||||
if (isSkeleton)
|
||||
nodedatas.skeleton.push_back(nodedata);
|
||||
nodedatas.skeleton.emplace_back(nodedata);
|
||||
else
|
||||
nodedatas.nodes.push_back(nodedata);
|
||||
nodedatas.nodes.emplace_back(nodedata);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1771,7 +1771,7 @@ NodeData* Bundle3D::parseNodesRecursivelyJson(const rapidjson::Value& jvalue, bo
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
modelnodedata->bones.push_back(bone[NODE].GetString());
|
||||
modelnodedata->bones.emplace_back(bone[NODE].GetString());
|
||||
|
||||
Mat4 invbindpos;
|
||||
const rapidjson::Value& jinvbindpos = bone[TRANSFORM];
|
||||
|
@ -1782,13 +1782,13 @@ NodeData* Bundle3D::parseNodesRecursivelyJson(const rapidjson::Value& jvalue, bo
|
|||
}
|
||||
|
||||
// invbindpos.inverse();
|
||||
modelnodedata->invBindPose.push_back(invbindpos);
|
||||
modelnodedata->invBindPose.emplace_back(invbindpos);
|
||||
}
|
||||
|
||||
if (bones.Size() > 0)
|
||||
isSkin = true;
|
||||
}
|
||||
nodedata->modelNodeDatas.push_back(modelnodedata);
|
||||
nodedata->modelNodeDatas.emplace_back(modelnodedata);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1818,7 +1818,7 @@ NodeData* Bundle3D::parseNodesRecursivelyJson(const rapidjson::Value& jvalue, bo
|
|||
const rapidjson::Value& child = children[i];
|
||||
|
||||
NodeData* tempdata = parseNodesRecursivelyJson(child, singleSprite);
|
||||
nodedata->children.push_back(tempdata);
|
||||
nodedata->children.emplace_back(tempdata);
|
||||
}
|
||||
}
|
||||
return nodedata;
|
||||
|
@ -1843,9 +1843,9 @@ bool Bundle3D::loadNodesBinary(NodeDatas& nodedatas)
|
|||
NodeData* nodedata = parseNodesRecursivelyBinary(skeleton, nodeSize == 1);
|
||||
|
||||
if (skeleton)
|
||||
nodedatas.skeleton.push_back(nodedata);
|
||||
nodedatas.skeleton.emplace_back(nodedata);
|
||||
else
|
||||
nodedatas.nodes.push_back(nodedata);
|
||||
nodedatas.nodes.emplace_back(nodedata);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1914,7 +1914,7 @@ NodeData* Bundle3D::parseNodesRecursivelyBinary(bool& skeleton, bool singleSprit
|
|||
for (unsigned int j = 0; j < bonesSize; ++j)
|
||||
{
|
||||
std::string name = _binaryReader.readString();
|
||||
modelnodedata->bones.push_back(name);
|
||||
modelnodedata->bones.emplace_back(name);
|
||||
|
||||
Mat4 invbindpos;
|
||||
if (!_binaryReader.readMatrix(invbindpos.m))
|
||||
|
@ -1924,7 +1924,7 @@ NodeData* Bundle3D::parseNodesRecursivelyBinary(bool& skeleton, bool singleSprit
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
modelnodedata->invBindPose.push_back(invbindpos);
|
||||
modelnodedata->invBindPose.emplace_back(invbindpos);
|
||||
}
|
||||
isSkin = true;
|
||||
}
|
||||
|
@ -1957,7 +1957,7 @@ NodeData* Bundle3D::parseNodesRecursivelyBinary(bool& skeleton, bool singleSprit
|
|||
}
|
||||
}
|
||||
}
|
||||
nodedata->modelNodeDatas.push_back(modelnodedata);
|
||||
nodedata->modelNodeDatas.emplace_back(modelnodedata);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1991,7 +1991,7 @@ NodeData* Bundle3D::parseNodesRecursivelyBinary(bool& skeleton, bool singleSprit
|
|||
for (unsigned int i = 0; i < childrenSize; ++i)
|
||||
{
|
||||
NodeData* tempdata = parseNodesRecursivelyBinary(skeleton, singleSprite);
|
||||
nodedata->children.push_back(tempdata);
|
||||
nodedata->children.emplace_back(tempdata);
|
||||
}
|
||||
}
|
||||
return nodedata;
|
||||
|
@ -2303,7 +2303,7 @@ std::vector<Vec3> Bundle3D::getTrianglesList(std::string_view path)
|
|||
for (const auto& indices : iter->subMeshIndices)
|
||||
{
|
||||
indices.for_each([&](unsigned int ind) {
|
||||
trianglesList.push_back(Vec3(iter->vertex[ind * preVertexSize], iter->vertex[ind * preVertexSize + 1],
|
||||
trianglesList.emplace_back(Vec3(iter->vertex[ind * preVertexSize], iter->vertex[ind * preVertexSize + 1],
|
||||
iter->vertex[ind * preVertexSize + 2]));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ public:
|
|||
|
||||
/** Pushes back a value. */
|
||||
template <typename _Ty = uint16_t, std::enable_if_t<is_index_format_type_v<_Ty>, int> = 0>
|
||||
void push_back(const _Ty& val)
|
||||
void emplace_back(const _Ty& val)
|
||||
{
|
||||
assert(_stride == sizeof(_Ty));
|
||||
_buffer.insert(_buffer.end(), &val, &val + 1);
|
||||
|
@ -408,14 +408,14 @@ struct SkinData
|
|||
{
|
||||
auto it = std::find(skinBoneNames.begin(), skinBoneNames.end(), name);
|
||||
if (it == skinBoneNames.end())
|
||||
skinBoneNames.push_back(std::string{name});
|
||||
skinBoneNames.emplace_back(std::string{name});
|
||||
}
|
||||
|
||||
void addNodeBoneNames(std::string_view name)
|
||||
{
|
||||
auto it = std::find(nodeBoneNames.begin(), nodeBoneNames.end(), name);
|
||||
if (it == nodeBoneNames.end())
|
||||
nodeBoneNames.push_back(std::string{name});
|
||||
nodeBoneNames.emplace_back(std::string{name});
|
||||
}
|
||||
|
||||
int getSkinBoneNameIndex(std::string_view name) const
|
||||
|
|
|
@ -207,7 +207,7 @@ inline bool BundleReader::readArray<std::string>(unsigned int* length, std::vect
|
|||
{
|
||||
for (int i = 0; i < (int)*length; ++i)
|
||||
{
|
||||
values->push_back(readString());
|
||||
values->emplace_back(readString());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -169,20 +169,20 @@ Mesh* Mesh::create(const std::vector<float>& positions,
|
|||
{
|
||||
perVertexSizeInFloat += 3;
|
||||
att.vertexAttrib = shaderinfos::VertexKey::VERTEX_ATTRIB_POSITION;
|
||||
attribs.push_back(att);
|
||||
attribs.emplace_back(att);
|
||||
}
|
||||
if (normals.size())
|
||||
{
|
||||
perVertexSizeInFloat += 3;
|
||||
att.vertexAttrib = shaderinfos::VertexKey::VERTEX_ATTRIB_NORMAL;
|
||||
attribs.push_back(att);
|
||||
attribs.emplace_back(att);
|
||||
}
|
||||
if (texs.size())
|
||||
{
|
||||
perVertexSizeInFloat += 2;
|
||||
att.type = backend::VertexFormat::FLOAT2;
|
||||
att.vertexAttrib = shaderinfos::VertexKey::VERTEX_ATTRIB_TEX_COORD;
|
||||
attribs.push_back(att);
|
||||
attribs.emplace_back(att);
|
||||
}
|
||||
|
||||
bool hasNormal = (normals.size() != 0);
|
||||
|
@ -191,21 +191,21 @@ Mesh* Mesh::create(const std::vector<float>& positions,
|
|||
size_t vertexNum = positions.size() / 3;
|
||||
for (size_t i = 0; i < vertexNum; i++)
|
||||
{
|
||||
vertices.push_back(positions[i * 3]);
|
||||
vertices.push_back(positions[i * 3 + 1]);
|
||||
vertices.push_back(positions[i * 3 + 2]);
|
||||
vertices.emplace_back(positions[i * 3]);
|
||||
vertices.emplace_back(positions[i * 3 + 1]);
|
||||
vertices.emplace_back(positions[i * 3 + 2]);
|
||||
|
||||
if (hasNormal)
|
||||
{
|
||||
vertices.push_back(normals[i * 3]);
|
||||
vertices.push_back(normals[i * 3 + 1]);
|
||||
vertices.push_back(normals[i * 3 + 2]);
|
||||
vertices.emplace_back(normals[i * 3]);
|
||||
vertices.emplace_back(normals[i * 3 + 1]);
|
||||
vertices.emplace_back(normals[i * 3 + 2]);
|
||||
}
|
||||
|
||||
if (hasTexCoord)
|
||||
{
|
||||
vertices.push_back(texs[i * 2]);
|
||||
vertices.push_back(texs[i * 2 + 1]);
|
||||
vertices.emplace_back(texs[i * 2]);
|
||||
vertices.emplace_back(texs[i * 2 + 1]);
|
||||
}
|
||||
}
|
||||
return create(vertices, perVertexSizeInFloat, indices, attribs);
|
||||
|
@ -219,8 +219,8 @@ Mesh* Mesh::create(const std::vector<float>& vertices,
|
|||
MeshData meshdata;
|
||||
meshdata.attribs = attribs;
|
||||
meshdata.vertex = vertices;
|
||||
meshdata.subMeshIndices.push_back(indices);
|
||||
meshdata.subMeshIds.push_back("");
|
||||
meshdata.subMeshIndices.emplace_back(indices);
|
||||
meshdata.subMeshIds.emplace_back("");
|
||||
auto meshvertexdata = MeshVertexData::create(meshdata, indices.format());
|
||||
auto indexData = meshvertexdata->getMeshIndexDataByIndex(0);
|
||||
|
||||
|
|
|
@ -934,7 +934,7 @@ std::vector<Mesh*> MeshRenderer::getMeshArrayByName(std::string_view name) const
|
|||
for (const auto& it : _meshes)
|
||||
{
|
||||
if (it->getName() == name)
|
||||
meshes.push_back(it);
|
||||
meshes.emplace_back(it);
|
||||
}
|
||||
return meshes;
|
||||
}
|
||||
|
|
|
@ -343,21 +343,21 @@ static unsigned int updateVertex(std::map<vertex_index, unsigned int>& vertexCac
|
|||
|
||||
assert(in_positions.size() > (unsigned int)(3 * i.v_idx + 2));
|
||||
|
||||
positions.push_back(in_positions[3 * i.v_idx + 0]);
|
||||
positions.push_back(in_positions[3 * i.v_idx + 1]);
|
||||
positions.push_back(in_positions[3 * i.v_idx + 2]);
|
||||
positions.emplace_back(in_positions[3 * i.v_idx + 0]);
|
||||
positions.emplace_back(in_positions[3 * i.v_idx + 1]);
|
||||
positions.emplace_back(in_positions[3 * i.v_idx + 2]);
|
||||
|
||||
if (i.vn_idx >= 0)
|
||||
{
|
||||
normals.push_back(in_normals[3 * i.vn_idx + 0]);
|
||||
normals.push_back(in_normals[3 * i.vn_idx + 1]);
|
||||
normals.push_back(in_normals[3 * i.vn_idx + 2]);
|
||||
normals.emplace_back(in_normals[3 * i.vn_idx + 0]);
|
||||
normals.emplace_back(in_normals[3 * i.vn_idx + 1]);
|
||||
normals.emplace_back(in_normals[3 * i.vn_idx + 2]);
|
||||
}
|
||||
|
||||
if (i.vt_idx >= 0)
|
||||
{
|
||||
texcoords.push_back(in_texcoords[2 * i.vt_idx + 0]);
|
||||
texcoords.push_back(in_texcoords[2 * i.vt_idx + 1]);
|
||||
texcoords.emplace_back(in_texcoords[2 * i.vt_idx + 0]);
|
||||
texcoords.emplace_back(in_texcoords[2 * i.vt_idx + 1]);
|
||||
}
|
||||
|
||||
unsigned int idx = static_cast<unsigned int>(positions.size() / 3 - 1);
|
||||
|
@ -427,11 +427,11 @@ static bool exportFaceGroupToShape(shape_t& shape,
|
|||
unsigned int v2 = updateVertex(vertexCache, shape.mesh.positions, shape.mesh.normals, shape.mesh.texcoords,
|
||||
in_positions, in_normals, in_texcoords, i2);
|
||||
|
||||
shape.mesh.indices.push_back(v0);
|
||||
shape.mesh.indices.push_back(v1);
|
||||
shape.mesh.indices.push_back(v2);
|
||||
shape.mesh.indices.emplace_back(v0);
|
||||
shape.mesh.indices.emplace_back(v1);
|
||||
shape.mesh.indices.emplace_back(v2);
|
||||
|
||||
shape.mesh.material_ids.push_back(material_id);
|
||||
shape.mesh.material_ids.emplace_back(material_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,7 +507,7 @@ std::string LoadMtl(std::map<std::string, int>& material_map,
|
|||
if (!material.name.empty())
|
||||
{
|
||||
material_map.insert(std::pair<std::string, int>(material.name, static_cast<int>(materials.size())));
|
||||
materials.push_back(material);
|
||||
materials.emplace_back(material);
|
||||
}
|
||||
|
||||
// initial temporary material
|
||||
|
@ -676,7 +676,7 @@ std::string LoadMtl(std::map<std::string, int>& material_map,
|
|||
}
|
||||
// flush last material.
|
||||
material_map.insert(std::pair<std::string, int>(material.name, static_cast<int>(materials.size())));
|
||||
materials.push_back(material);
|
||||
materials.emplace_back(material);
|
||||
|
||||
return err.str();
|
||||
}
|
||||
|
@ -800,9 +800,9 @@ std::string LoadObj(std::vector<shape_t>& shapes,
|
|||
token += 2;
|
||||
float x, y, z;
|
||||
parseFloat3(x, y, z, token);
|
||||
v.push_back(x);
|
||||
v.push_back(y);
|
||||
v.push_back(z);
|
||||
v.emplace_back(x);
|
||||
v.emplace_back(y);
|
||||
v.emplace_back(z);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -812,9 +812,9 @@ std::string LoadObj(std::vector<shape_t>& shapes,
|
|||
token += 3;
|
||||
float x, y, z;
|
||||
parseFloat3(x, y, z, token);
|
||||
vn.push_back(x);
|
||||
vn.push_back(y);
|
||||
vn.push_back(z);
|
||||
vn.emplace_back(x);
|
||||
vn.emplace_back(y);
|
||||
vn.emplace_back(z);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -824,8 +824,8 @@ std::string LoadObj(std::vector<shape_t>& shapes,
|
|||
token += 3;
|
||||
float x, y;
|
||||
parseFloat2(x, y, token);
|
||||
vt.push_back(x);
|
||||
vt.push_back(y);
|
||||
vt.emplace_back(x);
|
||||
vt.emplace_back(y);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -842,12 +842,12 @@ std::string LoadObj(std::vector<shape_t>& shapes,
|
|||
while (!isNewLine(token[0]))
|
||||
{
|
||||
vertex_index vi = parseTriple(token, first, second, third);
|
||||
face.push_back(vi);
|
||||
face.emplace_back(vi);
|
||||
size_t n = strspn(token, " \t\r");
|
||||
token += n;
|
||||
}
|
||||
|
||||
faceGroup.push_back(face);
|
||||
faceGroup.emplace_back(face);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -868,7 +868,7 @@ std::string LoadObj(std::vector<shape_t>& shapes,
|
|||
bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt, faceGroup, material, name, true);
|
||||
if (ret)
|
||||
{
|
||||
shapes.push_back(shape);
|
||||
shapes.emplace_back(shape);
|
||||
}
|
||||
shape = shape_t();
|
||||
faceGroup.clear();
|
||||
|
@ -915,7 +915,7 @@ std::string LoadObj(std::vector<shape_t>& shapes,
|
|||
bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt, faceGroup, material, name, true);
|
||||
if (ret)
|
||||
{
|
||||
shapes.push_back(shape);
|
||||
shapes.emplace_back(shape);
|
||||
}
|
||||
|
||||
shape = shape_t();
|
||||
|
@ -927,7 +927,7 @@ std::string LoadObj(std::vector<shape_t>& shapes,
|
|||
while (!isNewLine(token[0]))
|
||||
{
|
||||
std::string str = parseString(token);
|
||||
names.push_back(str);
|
||||
names.emplace_back(str);
|
||||
token += strspn(token, " \t\r"); // skip tag
|
||||
}
|
||||
|
||||
|
@ -954,7 +954,7 @@ std::string LoadObj(std::vector<shape_t>& shapes,
|
|||
bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt, faceGroup, material, name, true);
|
||||
if (ret)
|
||||
{
|
||||
shapes.push_back(shape);
|
||||
shapes.emplace_back(shape);
|
||||
}
|
||||
|
||||
// material = -1;
|
||||
|
@ -980,7 +980,7 @@ std::string LoadObj(std::vector<shape_t>& shapes,
|
|||
bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt, faceGroup, material, name, true);
|
||||
if (ret)
|
||||
{
|
||||
shapes.push_back(shape);
|
||||
shapes.emplace_back(shape);
|
||||
}
|
||||
faceGroup.clear(); // for safety
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ void Bone3D::setAnimationValue(float* trans, float* rot, float* scale, void* tag
|
|||
state.weight = weight;
|
||||
state.tag = tag;
|
||||
|
||||
_blendStates.push_back(state);
|
||||
_blendStates.emplace_back(state);
|
||||
}
|
||||
|
||||
void Bone3D::clearBoneBlendState()
|
||||
|
|
|
@ -393,7 +393,7 @@ void Terrain::loadVertices()
|
|||
height, // y
|
||||
i * _terrainData._mapScale - _imageHeight / 2 * _terrainData._mapScale); // z
|
||||
v._texcoord = Tex2F(j * 1.0 / _imageWidth, i * 1.0 / _imageHeight);
|
||||
_vertices.push_back(v);
|
||||
_vertices.emplace_back(v);
|
||||
|
||||
// update the min & max height;
|
||||
if (height > _maxHeight)
|
||||
|
@ -414,13 +414,13 @@ void Terrain::calculateNormal()
|
|||
{
|
||||
|
||||
int nLocIndex = i * _imageWidth + j;
|
||||
_indices.push_back(nLocIndex);
|
||||
_indices.push_back(nLocIndex + _imageWidth);
|
||||
_indices.push_back(nLocIndex + 1);
|
||||
_indices.emplace_back(nLocIndex);
|
||||
_indices.emplace_back(nLocIndex + _imageWidth);
|
||||
_indices.emplace_back(nLocIndex + 1);
|
||||
|
||||
_indices.push_back(nLocIndex + 1);
|
||||
_indices.push_back(nLocIndex + _imageWidth);
|
||||
_indices.push_back(nLocIndex + _imageWidth + 1);
|
||||
_indices.emplace_back(nLocIndex + 1);
|
||||
_indices.emplace_back(nLocIndex + _imageWidth);
|
||||
_indices.emplace_back(nLocIndex + _imageWidth + 1);
|
||||
}
|
||||
}
|
||||
for (size_t i = 0, size = _indices.size(); i < size; i += 3)
|
||||
|
@ -740,7 +740,7 @@ Terrain::ChunkIndices Terrain::insertIndicesLOD(int neighborLod[4], int selfLod,
|
|||
|
||||
AX_SAFE_RELEASE_NULL(lodIndices._chunkIndices._indexBuffer);
|
||||
lodIndices._chunkIndices._indexBuffer = buffer;
|
||||
this->_chunkLodIndicesSet.push_back(lodIndices);
|
||||
this->_chunkLodIndicesSet.emplace_back(lodIndices);
|
||||
return lodIndices._chunkIndices;
|
||||
}
|
||||
|
||||
|
@ -778,7 +778,7 @@ Terrain::ChunkIndices Terrain::insertIndicesLODSkirt(int selfLod, uint16_t* indi
|
|||
|
||||
AX_SAFE_RELEASE_NULL(skirtIndices._chunkIndices._indexBuffer);
|
||||
skirtIndices._chunkIndices._indexBuffer = buffer;
|
||||
this->_chunkLodIndicesSkirtSet.push_back(skirtIndices);
|
||||
this->_chunkLodIndicesSkirtSet.emplace_back(skirtIndices);
|
||||
return skirtIndices._chunkIndices;
|
||||
}
|
||||
|
||||
|
@ -997,7 +997,7 @@ void Terrain::Chunk::generate(int imgWidth, int imageHei, int m, int n, const un
|
|||
if (j >= imgWidth)
|
||||
break;
|
||||
auto v = _terrain->_vertices[i * imgWidth + j];
|
||||
_originalVertices.push_back(v);
|
||||
_originalVertices.emplace_back(v);
|
||||
}
|
||||
}
|
||||
// add four skirts
|
||||
|
@ -1009,7 +1009,7 @@ void Terrain::Chunk::generate(int imgWidth, int imageHei, int m, int n, const un
|
|||
{
|
||||
auto v = _terrain->_vertices[i * imgWidth + _size.width * (n + 1)];
|
||||
v._position.y -= skirtHeight;
|
||||
_originalVertices.push_back(v);
|
||||
_originalVertices.emplace_back(v);
|
||||
}
|
||||
|
||||
//#2
|
||||
|
@ -1018,7 +1018,7 @@ void Terrain::Chunk::generate(int imgWidth, int imageHei, int m, int n, const un
|
|||
{
|
||||
auto v = _terrain->_vertices[_size.height * (m + 1) * imgWidth + j];
|
||||
v._position.y -= skirtHeight;
|
||||
_originalVertices.push_back(v);
|
||||
_originalVertices.emplace_back(v);
|
||||
}
|
||||
|
||||
//#3
|
||||
|
@ -1027,7 +1027,7 @@ void Terrain::Chunk::generate(int imgWidth, int imageHei, int m, int n, const un
|
|||
{
|
||||
auto v = _terrain->_vertices[i * imgWidth + _size.width * n];
|
||||
v._position.y -= skirtHeight;
|
||||
_originalVertices.push_back(v);
|
||||
_originalVertices.emplace_back(v);
|
||||
}
|
||||
|
||||
//#4
|
||||
|
@ -1037,7 +1037,7 @@ void Terrain::Chunk::generate(int imgWidth, int imageHei, int m, int n, const un
|
|||
auto v = _terrain->_vertices[_size.height * m * imgWidth + j];
|
||||
v._position.y -= skirtHeight;
|
||||
// v.position.y = -5;
|
||||
_originalVertices.push_back(v);
|
||||
_originalVertices.emplace_back(v);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1052,7 +1052,7 @@ void Terrain::Chunk::generate(int imgWidth, int imageHei, int m, int n, const un
|
|||
if (j >= imgWidth)
|
||||
break;
|
||||
auto v = _terrain->_vertices[i * imgWidth + j];
|
||||
_originalVertices.push_back(v);
|
||||
_originalVertices.emplace_back(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1071,8 +1071,8 @@ void Terrain::Chunk::generate(int imgWidth, int imageHei, int m, int n, const un
|
|||
_originalVertices[nLocIndex + 1 * (_size.width + 1)]._position,
|
||||
_originalVertices[nLocIndex + 1 * (_size.width + 1) + 1]._position);
|
||||
|
||||
_trianglesList.push_back(a);
|
||||
_trianglesList.push_back(b);
|
||||
_trianglesList.emplace_back(a);
|
||||
_trianglesList.emplace_back(b);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1169,13 +1169,13 @@ void Terrain::Chunk::updateIndicesLOD()
|
|||
for (int j = step; j < gridX - step; j += step)
|
||||
{
|
||||
int nLocIndex = i * (gridX + 1) + j;
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step * (gridX + 1) + step);
|
||||
}
|
||||
}
|
||||
// fix T-crack
|
||||
|
@ -1184,17 +1184,17 @@ void Terrain::Chunk::updateIndicesLOD()
|
|||
{
|
||||
for (int i = 0; i < gridY; i += next_step)
|
||||
{
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back((i + next_step) * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back((i + next_step) * (gridX + 1));
|
||||
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.push_back((i + next_step) * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back((i + step) * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.emplace_back((i + next_step) * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back((i + step) * (gridX + 1) + step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back((i + step) * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.push_back((i + next_step) * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back((i + next_step) * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.emplace_back((i + step) * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.emplace_back((i + next_step) * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back((i + next_step) * (gridX + 1) + step);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1207,13 +1207,13 @@ void Terrain::Chunk::updateIndicesLOD()
|
|||
start += step;
|
||||
for (int i = start; i < end; i += step)
|
||||
{
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back((i + step) * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back((i + step) * (gridX + 1));
|
||||
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.push_back((i + step) * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back((i + step) * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.emplace_back((i + step) * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back((i + step) * (gridX + 1) + step);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1221,17 +1221,17 @@ void Terrain::Chunk::updateIndicesLOD()
|
|||
{
|
||||
for (int i = 0; i < gridY; i += next_step)
|
||||
{
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1) + gridX);
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.push_back((i + step) * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1) + gridX);
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.emplace_back((i + step) * (gridX + 1) + gridX - step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1) + gridX);
|
||||
_lod[_currentLod]._indices.push_back((i + step) * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.push_back((i + next_step) * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1) + gridX);
|
||||
_lod[_currentLod]._indices.emplace_back((i + step) * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.emplace_back((i + next_step) * (gridX + 1) + gridX - step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1) + gridX);
|
||||
_lod[_currentLod]._indices.push_back((i + next_step) * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.push_back((i + next_step) * (gridX + 1) + gridX);
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1) + gridX);
|
||||
_lod[_currentLod]._indices.emplace_back((i + next_step) * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.emplace_back((i + next_step) * (gridX + 1) + gridX);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1244,73 +1244,73 @@ void Terrain::Chunk::updateIndicesLOD()
|
|||
start += step;
|
||||
for (int i = start; i < end; i += step)
|
||||
{
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1) + gridX);
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.push_back((i + step) * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1) + gridX);
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.emplace_back((i + step) * (gridX + 1) + gridX - step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back(i * (gridX + 1) + gridX);
|
||||
_lod[_currentLod]._indices.push_back((i + step) * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.push_back((i + step) * (gridX + 1) + gridX);
|
||||
_lod[_currentLod]._indices.emplace_back(i * (gridX + 1) + gridX);
|
||||
_lod[_currentLod]._indices.emplace_back((i + step) * (gridX + 1) + gridX - step);
|
||||
_lod[_currentLod]._indices.emplace_back((i + step) * (gridX + 1) + gridX);
|
||||
}
|
||||
}
|
||||
if (_front && _front->_currentLod > _currentLod) // front
|
||||
{
|
||||
for (int i = 0; i < gridX; i += next_step)
|
||||
{
|
||||
_lod[_currentLod]._indices.push_back((gridY - step) * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.push_back(gridY * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.push_back((gridY - step) * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back((gridY - step) * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.emplace_back(gridY * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.emplace_back((gridY - step) * (gridX + 1) + i + step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back((gridY - step) * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.push_back(gridY * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.push_back(gridY * (gridX + 1) + i + next_step);
|
||||
_lod[_currentLod]._indices.emplace_back((gridY - step) * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back(gridY * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.emplace_back(gridY * (gridX + 1) + i + next_step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back((gridY - step) * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.push_back(gridY * (gridX + 1) + i + next_step);
|
||||
_lod[_currentLod]._indices.push_back((gridY - step) * (gridX + 1) + i + next_step);
|
||||
_lod[_currentLod]._indices.emplace_back((gridY - step) * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back(gridY * (gridX + 1) + i + next_step);
|
||||
_lod[_currentLod]._indices.emplace_back((gridY - step) * (gridX + 1) + i + next_step);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = step; i < gridX - step; i += step)
|
||||
{
|
||||
_lod[_currentLod]._indices.push_back((gridY - step) * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.push_back(gridY * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.push_back((gridY - step) * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back((gridY - step) * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.emplace_back(gridY * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.emplace_back((gridY - step) * (gridX + 1) + i + step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back((gridY - step) * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.push_back(gridY * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.push_back(gridY * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back((gridY - step) * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back(gridY * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.emplace_back(gridY * (gridX + 1) + i + step);
|
||||
}
|
||||
}
|
||||
if (_back && _back->_currentLod > _currentLod) // back
|
||||
{
|
||||
for (int i = 0; i < gridX; i += next_step)
|
||||
{
|
||||
_lod[_currentLod]._indices.push_back(i);
|
||||
_lod[_currentLod]._indices.push_back(step * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.push_back(step * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back(i);
|
||||
_lod[_currentLod]._indices.emplace_back(step * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.emplace_back(step * (gridX + 1) + i + step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back(i);
|
||||
_lod[_currentLod]._indices.push_back(step * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.push_back(i + next_step);
|
||||
_lod[_currentLod]._indices.emplace_back(i);
|
||||
_lod[_currentLod]._indices.emplace_back(step * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back(i + next_step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back(i + next_step);
|
||||
_lod[_currentLod]._indices.push_back(step * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.push_back(step * (gridX + 1) + i + next_step);
|
||||
_lod[_currentLod]._indices.emplace_back(i + next_step);
|
||||
_lod[_currentLod]._indices.emplace_back(step * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back(step * (gridX + 1) + i + next_step);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = step; i < gridX - step; i += step)
|
||||
{
|
||||
_lod[_currentLod]._indices.push_back(i);
|
||||
_lod[_currentLod]._indices.push_back(step * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.push_back(step * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back(i);
|
||||
_lod[_currentLod]._indices.emplace_back(step * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.emplace_back(step * (gridX + 1) + i + step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back(i);
|
||||
_lod[_currentLod]._indices.push_back(step * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.push_back(i + step);
|
||||
_lod[_currentLod]._indices.emplace_back(i);
|
||||
_lod[_currentLod]._indices.emplace_back(step * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back(i + step);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1327,13 +1327,13 @@ void Terrain::Chunk::updateIndicesLOD()
|
|||
{
|
||||
|
||||
int nLocIndex = i * (gridX + 1) + j;
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step * (gridX + 1) + step);
|
||||
}
|
||||
}
|
||||
_chunkIndices = _terrain->insertIndicesLOD(currentNeighborLOD, _currentLod, &_lod[_currentLod]._indices[0],
|
||||
|
@ -1346,7 +1346,7 @@ void Terrain::Chunk::calculateAABB()
|
|||
std::vector<Vec3> pos;
|
||||
for (size_t i = 0, size = _originalVertices.size(); i < size; ++i)
|
||||
{
|
||||
pos.push_back(_originalVertices[i]._position);
|
||||
pos.emplace_back(_originalVertices[i]._position);
|
||||
}
|
||||
_aabb.updateMinMax(&pos[0], pos.size());
|
||||
}
|
||||
|
@ -1460,13 +1460,13 @@ void Terrain::Chunk::updateIndicesLODSkirt()
|
|||
for (int j = 0; j < gridX; j += step)
|
||||
{
|
||||
int nLocIndex = i * (gridX + 1) + j;
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step * (gridX + 1) + step);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step * (gridX + 1) + step);
|
||||
}
|
||||
}
|
||||
// add skirt
|
||||
|
@ -1474,52 +1474,52 @@ void Terrain::Chunk::updateIndicesLODSkirt()
|
|||
for (int i = 0; i < gridY; i += step)
|
||||
{
|
||||
int nLocIndex = i * (gridX + 1) + gridX;
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back((gridY + 1) * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back((gridY + 1) * (gridX + 1) + i);
|
||||
|
||||
_lod[_currentLod]._indices.push_back((gridY + 1) * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back((gridY + 1) * (gridX + 1) + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back((gridY + 1) * (gridX + 1) + i);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back((gridY + 1) * (gridX + 1) + i + step);
|
||||
}
|
||||
|
||||
//#2
|
||||
for (int j = 0; j < gridX; j += step)
|
||||
{
|
||||
int nLocIndex = (gridY) * (gridX + 1) + j;
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.push_back(_terrain->_skirtVerticesOffset[1] + j);
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.emplace_back(_terrain->_skirtVerticesOffset[1] + j);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step);
|
||||
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.push_back(_terrain->_skirtVerticesOffset[1] + j);
|
||||
_lod[_currentLod]._indices.push_back(_terrain->_skirtVerticesOffset[1] + j + step);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.emplace_back(_terrain->_skirtVerticesOffset[1] + j);
|
||||
_lod[_currentLod]._indices.emplace_back(_terrain->_skirtVerticesOffset[1] + j + step);
|
||||
}
|
||||
|
||||
//#3
|
||||
for (int i = 0; i < gridY; i += step)
|
||||
{
|
||||
int nLocIndex = i * (gridX + 1);
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.push_back(_terrain->_skirtVerticesOffset[2] + i);
|
||||
_lod[_currentLod]._indices.push_back((i + step) * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.emplace_back(_terrain->_skirtVerticesOffset[2] + i);
|
||||
_lod[_currentLod]._indices.emplace_back((i + step) * (gridX + 1));
|
||||
|
||||
_lod[_currentLod]._indices.push_back((i + step) * (gridX + 1));
|
||||
_lod[_currentLod]._indices.push_back(_terrain->_skirtVerticesOffset[2] + i);
|
||||
_lod[_currentLod]._indices.push_back(_terrain->_skirtVerticesOffset[2] + i + step);
|
||||
_lod[_currentLod]._indices.emplace_back((i + step) * (gridX + 1));
|
||||
_lod[_currentLod]._indices.emplace_back(_terrain->_skirtVerticesOffset[2] + i);
|
||||
_lod[_currentLod]._indices.emplace_back(_terrain->_skirtVerticesOffset[2] + i + step);
|
||||
}
|
||||
|
||||
//#4
|
||||
for (int j = 0; j < gridX; j += step)
|
||||
{
|
||||
int nLocIndex = j;
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.push_back(_terrain->_skirtVerticesOffset[3] + j);
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.emplace_back(_terrain->_skirtVerticesOffset[3] + j);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex);
|
||||
|
||||
_lod[_currentLod]._indices.push_back(_terrain->_skirtVerticesOffset[3] + j + step);
|
||||
_lod[_currentLod]._indices.push_back(_terrain->_skirtVerticesOffset[3] + j);
|
||||
_lod[_currentLod]._indices.push_back(nLocIndex + step);
|
||||
_lod[_currentLod]._indices.emplace_back(_terrain->_skirtVerticesOffset[3] + j + step);
|
||||
_lod[_currentLod]._indices.emplace_back(_terrain->_skirtVerticesOffset[3] + j);
|
||||
_lod[_currentLod]._indices.emplace_back(nLocIndex + step);
|
||||
}
|
||||
|
||||
_chunkIndices = _terrain->insertIndicesLODSkirt(_currentLod, &_lod[_currentLod]._indices[0],
|
||||
|
|
|
@ -69,7 +69,7 @@ VertexAttribBinding* VertexAttribBinding::create(MeshIndexData* meshIndexData, P
|
|||
if (b->init(meshIndexData, pass, command))
|
||||
{
|
||||
b->autorelease();
|
||||
__vertexAttribBindingCache.push_back(b);
|
||||
__vertexAttribBindingCache.emplace_back(b);
|
||||
}
|
||||
|
||||
return b;
|
||||
|
|
|
@ -349,7 +349,7 @@ void AudioCache::addPlayCallback(const std::function<void()>& callback)
|
|||
{
|
||||
case State::INITIAL:
|
||||
case State::LOADING:
|
||||
_playCallbacks.push_back(callback);
|
||||
_playCallbacks.emplace_back(callback);
|
||||
break;
|
||||
|
||||
case State::READY:
|
||||
|
@ -383,7 +383,7 @@ void AudioCache::addLoadCallback(const std::function<void(bool)>& callback)
|
|||
{
|
||||
case State::INITIAL:
|
||||
case State::LOADING:
|
||||
_loadCallbacks.push_back(callback);
|
||||
_loadCallbacks.emplace_back(callback);
|
||||
break;
|
||||
|
||||
case State::READY:
|
||||
|
|
|
@ -238,7 +238,7 @@ AUDIO_ID AudioEngine::play2d(std::string_view filePath, bool loop, float volume,
|
|||
ret = _audioEngineImpl->play2d(filePath, loop, volume);
|
||||
if (ret != INVALID_AUDIO_ID)
|
||||
{
|
||||
_audioPathIDMap[filePath.data()].push_back(ret);
|
||||
_audioPathIDMap[filePath.data()].emplace_back(ret);
|
||||
auto it = _audioPathIDMap.find(filePath);
|
||||
|
||||
auto& audioRef = _audioIDInfoMap[ret];
|
||||
|
@ -249,7 +249,7 @@ AUDIO_ID AudioEngine::play2d(std::string_view filePath, bool loop, float volume,
|
|||
if (profileHelper)
|
||||
{
|
||||
profileHelper->lastPlayTime = utils::gettime();
|
||||
profileHelper->audioIDs.push_back(ret);
|
||||
profileHelper->audioIDs.emplace_back(ret);
|
||||
}
|
||||
audioRef.profileHelper = profileHelper;
|
||||
}
|
||||
|
|
|
@ -816,7 +816,7 @@ void AudioEngineImpl::_updatePlayers(bool forStop)
|
|||
{
|
||||
/// ###IMPORTANT: don't call immidiately, because at callback, user-end may play a new audio
|
||||
/// cause _audioPlayers' iterator goan to invalid.
|
||||
_finishCallbacks.push_back([finishCallback = std::move(player->_finishCallbak), audioID,
|
||||
_finishCallbacks.emplace_back([finishCallback = std::move(player->_finishCallbak), audioID,
|
||||
filePath = std::move(filePath)]() { finishCallback(audioID, filePath); });
|
||||
}
|
||||
// clear cache when audio player finsihed properly
|
||||
|
|
|
@ -58,7 +58,7 @@ AutoreleasePool::~AutoreleasePool()
|
|||
|
||||
void AutoreleasePool::addObject(Ref* object)
|
||||
{
|
||||
_managedObjectArray.push_back(object);
|
||||
_managedObjectArray.emplace_back(object);
|
||||
}
|
||||
|
||||
void AutoreleasePool::clear()
|
||||
|
@ -157,7 +157,7 @@ bool PoolManager::isObjectInPools(Ref* obj) const
|
|||
|
||||
void PoolManager::push(AutoreleasePool* pool)
|
||||
{
|
||||
_releasePoolStack.push_back(pool);
|
||||
_releasePoolStack.emplace_back(pool);
|
||||
}
|
||||
|
||||
void PoolManager::pop()
|
||||
|
|
|
@ -211,7 +211,7 @@ std::vector<std::string>& Console::Utility::split(std::string_view s, char delim
|
|||
std::string item;
|
||||
while (std::getline(ss, item, delim))
|
||||
{
|
||||
elems.push_back(item);
|
||||
elems.emplace_back(item);
|
||||
}
|
||||
return elems;
|
||||
}
|
||||
|
@ -697,7 +697,7 @@ void Console::log(const char* buf)
|
|||
if (_sendDebugStrings)
|
||||
{
|
||||
_DebugStringsMutex.lock();
|
||||
_DebugStrings.push_back(buf);
|
||||
_DebugStrings.emplace_back(buf);
|
||||
_DebugStringsMutex.unlock();
|
||||
}
|
||||
}
|
||||
|
@ -784,13 +784,13 @@ void Console::loop()
|
|||
{
|
||||
// no data received, or fd is closed
|
||||
// fix #18620. readable and no pending data means that the fd is closed.
|
||||
to_remove.push_back(fd);
|
||||
to_remove.emplace_back(fd);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!parseCommand(fd))
|
||||
{
|
||||
to_remove.push_back(fd);
|
||||
to_remove.emplace_back(fd);
|
||||
}
|
||||
if (--nready <= 0)
|
||||
break;
|
||||
|
@ -1017,7 +1017,7 @@ void Console::addClient()
|
|||
if (fd != -1)
|
||||
{
|
||||
FD_SET(fd, &_read_set);
|
||||
_fds.push_back(fd);
|
||||
_fds.emplace_back(fd);
|
||||
_maxfd = (std::max)(_maxfd, fd);
|
||||
|
||||
Console::Utility::sendPrompt(fd);
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
auto controller = new axis::Controller();
|
||||
controller->_deviceId = deviceId;
|
||||
controller->_deviceName = deviceName;
|
||||
Controller::s_allController.push_back(controller);
|
||||
Controller::s_allController.emplace_back(controller);
|
||||
|
||||
controller->onConnected();
|
||||
}
|
||||
|
|
|
@ -4214,7 +4214,7 @@ public:
|
|||
auto controller = new axis::Controller();
|
||||
controller->_deviceId = deviceId;
|
||||
controller->_deviceName = deviceName;
|
||||
Controller::s_allController.push_back(controller);
|
||||
Controller::s_allController.emplace_back(controller);
|
||||
|
||||
// Check if we already have an available input controller profile. If so, attach it it to the controller.
|
||||
for (const auto& it : s_controllerProfiles)
|
||||
|
|
|
@ -132,7 +132,7 @@ bool EventDispatcher::EventListenerVector::empty() const
|
|||
(_fixedListeners == nullptr || _fixedListeners->empty());
|
||||
}
|
||||
|
||||
void EventDispatcher::EventListenerVector::push_back(EventListener* listener)
|
||||
void EventDispatcher::EventListenerVector::emplace_back(EventListener* listener)
|
||||
{
|
||||
#if AX_NODE_DEBUG_VERIFY_EVENT_LISTENERS
|
||||
AXASSERT(_sceneGraphListeners == nullptr ||
|
||||
|
@ -151,7 +151,7 @@ void EventDispatcher::EventListenerVector::push_back(EventListener* listener)
|
|||
_sceneGraphListeners->reserve(100);
|
||||
}
|
||||
|
||||
_sceneGraphListeners->push_back(listener);
|
||||
_sceneGraphListeners->emplace_back(listener);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ void EventDispatcher::EventListenerVector::push_back(EventListener* listener)
|
|||
_fixedListeners->reserve(100);
|
||||
}
|
||||
|
||||
_fixedListeners->push_back(listener);
|
||||
_fixedListeners->emplace_back(listener);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ void EventDispatcher::visitTarget(Node* node, bool isRootNode)
|
|||
|
||||
if (_nodeListenersMap.find(node) != _nodeListenersMap.end())
|
||||
{
|
||||
_globalZOrderNodeMap[node->getGlobalZOrder()].push_back(node);
|
||||
_globalZOrderNodeMap[node->getGlobalZOrder()].emplace_back(node);
|
||||
}
|
||||
|
||||
for (; i < childrenCount; i++)
|
||||
|
@ -250,7 +250,7 @@ void EventDispatcher::visitTarget(Node* node, bool isRootNode)
|
|||
{
|
||||
if (_nodeListenersMap.find(node) != _nodeListenersMap.end())
|
||||
{
|
||||
_globalZOrderNodeMap[node->getGlobalZOrder()].push_back(node);
|
||||
_globalZOrderNodeMap[node->getGlobalZOrder()].emplace_back(node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,7 @@ void EventDispatcher::visitTarget(Node* node, bool isRootNode)
|
|||
|
||||
for (const auto& e : _globalZOrderNodeMap)
|
||||
{
|
||||
globalZOrders.push_back(e.first);
|
||||
globalZOrders.emplace_back(e.first);
|
||||
}
|
||||
|
||||
std::stable_sort(globalZOrders.begin(), globalZOrders.end(),
|
||||
|
@ -405,7 +405,7 @@ void EventDispatcher::associateNodeAndEventListener(Node* node, EventListener* l
|
|||
_nodeListenersMap.emplace(node, listeners);
|
||||
}
|
||||
|
||||
listeners->push_back(listener);
|
||||
listeners->emplace_back(listener);
|
||||
}
|
||||
|
||||
void EventDispatcher::dissociateNodeAndEventListener(Node* node, EventListener* listener)
|
||||
|
@ -437,7 +437,7 @@ void EventDispatcher::addEventListener(EventListener* listener)
|
|||
}
|
||||
else
|
||||
{
|
||||
_toAddedListeners.push_back(listener);
|
||||
_toAddedListeners.emplace_back(listener);
|
||||
}
|
||||
#if AX_ENABLE_GC_FOR_NATIVE_OBJECTS
|
||||
auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine();
|
||||
|
@ -465,7 +465,7 @@ void EventDispatcher::forceAddEventListener(EventListener* listener)
|
|||
listeners = itr->second;
|
||||
}
|
||||
|
||||
listeners->push_back(listener);
|
||||
listeners->emplace_back(listener);
|
||||
|
||||
if (listener->getFixedPriority() == 0)
|
||||
{
|
||||
|
@ -623,7 +623,7 @@ void EventDispatcher::removeEventListener(EventListener* listener)
|
|||
}
|
||||
else
|
||||
{
|
||||
_toRemovedListeners.push_back(l);
|
||||
_toRemovedListeners.emplace_back(l);
|
||||
}
|
||||
|
||||
isFound = true;
|
||||
|
@ -831,7 +831,7 @@ void EventDispatcher::dispatchTouchEventToListeners(EventListenerVector* listene
|
|||
{
|
||||
if (l->isEnabled() && !l->isPaused() && l->isRegistered())
|
||||
{
|
||||
sceneListeners.push_back(l);
|
||||
sceneListeners.emplace_back(l);
|
||||
}
|
||||
}
|
||||
// second, for all camera call all listeners
|
||||
|
@ -993,7 +993,7 @@ void EventDispatcher::dispatchTouchEvent(EventTouch* event)
|
|||
isClaimed = listener->onTouchBegan(touches, event);
|
||||
if (isClaimed && listener->_isRegistered)
|
||||
{
|
||||
listener->_claimedTouches.push_back(touches);
|
||||
listener->_claimedTouches.emplace_back(touches);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1497,7 +1497,7 @@ void EventDispatcher::removeAllEventListeners()
|
|||
}
|
||||
else
|
||||
{
|
||||
types.push_back(e.first);
|
||||
types.emplace_back(e.first);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ protected:
|
|||
size_t size() const;
|
||||
bool empty() const;
|
||||
|
||||
void push_back(EventListener* item);
|
||||
void emplace_back(EventListener* item);
|
||||
void clearSceneGraphListeners();
|
||||
void clearFixedListeners();
|
||||
void clear();
|
||||
|
|
|
@ -187,7 +187,7 @@ public:
|
|||
|
||||
for (const auto& iter : _data)
|
||||
{
|
||||
keys.push_back(iter.first);
|
||||
keys.emplace_back(iter.first);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
|
@ -206,7 +206,7 @@ public:
|
|||
{
|
||||
if (iter.second == object)
|
||||
{
|
||||
keys.push_back(iter.first);
|
||||
keys.emplace_back(iter.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@ static inline void split(std::string_view src, std::string_view token, strArray&
|
|||
{
|
||||
nend = src.find(token, nbegin);
|
||||
if (nend == std::string::npos)
|
||||
vect.push_back(std::string{src.substr(nbegin, src.length() - nbegin)});
|
||||
vect.emplace_back(std::string{src.substr(nbegin, src.length() - nbegin)});
|
||||
else
|
||||
vect.push_back(std::string{src.substr(nbegin, nend - nbegin)});
|
||||
vect.emplace_back(std::string{src.substr(nbegin, nend - nbegin)});
|
||||
nbegin = nend + tokenSize;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ Properties::Properties(const Properties& copy)
|
|||
|
||||
for (const auto space : copy._namespaces)
|
||||
{
|
||||
_namespaces.push_back(new Properties(*space));
|
||||
_namespaces.emplace_back(new Properties(*space));
|
||||
}
|
||||
rewind();
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ void Properties::readProperties()
|
|||
else
|
||||
{
|
||||
// Normal name/value pair
|
||||
_properties.push_back(Property(name, value));
|
||||
_properties.emplace_back(Property(name, value));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -319,7 +319,7 @@ void Properties::readProperties()
|
|||
|
||||
// New namespace without an ID.
|
||||
Properties* space = new Properties(_data, _dataIdx, name, NULL, parentID, this);
|
||||
_namespaces.push_back(space);
|
||||
_namespaces.emplace_back(space);
|
||||
|
||||
// If the namespace ends on this line, seek to right after the '}' character.
|
||||
if (rccc && rccc == lineEnd)
|
||||
|
@ -361,7 +361,7 @@ void Properties::readProperties()
|
|||
|
||||
// Create new namespace.
|
||||
Properties* space = new Properties(_data, _dataIdx, name, value, parentID, this);
|
||||
_namespaces.push_back(space);
|
||||
_namespaces.emplace_back(space);
|
||||
|
||||
// If the namespace ends on this line, seek to right after the '}' character.
|
||||
if (rccc && rccc == lineEnd)
|
||||
|
@ -382,7 +382,7 @@ void Properties::readProperties()
|
|||
{
|
||||
// Create new namespace.
|
||||
Properties* space = new Properties(_data, _dataIdx, name, value, parentID, this);
|
||||
_namespaces.push_back(space);
|
||||
_namespaces.emplace_back(space);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -395,11 +395,11 @@ void Properties::readProperties()
|
|||
// Store "name value" as a name/value pair, or even just "name".
|
||||
if (value != NULL)
|
||||
{
|
||||
_properties.push_back(Property(name, value));
|
||||
_properties.emplace_back(Property(name, value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_properties.push_back(Property(name, ""));
|
||||
_properties.emplace_back(Property(name, ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ void Properties::resolveInheritance(const char* id)
|
|||
std::vector<Properties*>::const_iterator itt;
|
||||
for (const auto space : parent->_namespaces)
|
||||
{
|
||||
derived->_namespaces.push_back(new Properties(*space));
|
||||
derived->_namespaces.emplace_back(new Properties(*space));
|
||||
}
|
||||
derived->rewind();
|
||||
|
||||
|
@ -621,7 +621,7 @@ void Properties::mergeWith(Properties* overrides)
|
|||
// Add this new namespace.
|
||||
Properties* newNamespace = new Properties(*overridesNamespace);
|
||||
|
||||
this->_namespaces.push_back(newNamespace);
|
||||
this->_namespaces.emplace_back(newNamespace);
|
||||
this->_namespacesItr = this->_namespaces.end();
|
||||
}
|
||||
|
||||
|
@ -844,7 +844,7 @@ bool Properties::setString(const char* name, const char* value)
|
|||
}
|
||||
|
||||
// There is no property with this name, so add one
|
||||
_properties.push_back(Property(name, value ? value : ""));
|
||||
_properties.emplace_back(Property(name, value ? value : ""));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1054,7 +1054,7 @@ void Properties::setVariable(const char* name, const char* value)
|
|||
// Add a new variable with this name
|
||||
if (!_variables)
|
||||
_variables = new std::vector<Property>();
|
||||
_variables->push_back(Property(name, value ? value : ""));
|
||||
_variables->emplace_back(Property(name, value ? value : ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1073,7 +1073,7 @@ Properties* Properties::clone()
|
|||
{
|
||||
AXASSERT(_namespaces[i], "Invalid namespace");
|
||||
Properties* child = _namespaces[i]->clone();
|
||||
p->_namespaces.push_back(child);
|
||||
p->_namespaces.emplace_back(child);
|
||||
child->_parent = p;
|
||||
}
|
||||
p->_namespacesItr = p->_namespaces.end();
|
||||
|
@ -1118,10 +1118,10 @@ void calculateNamespacePath(std::string_view urlString,
|
|||
auto namespacePathString = urlString.substr(loc + 1);
|
||||
while ((loc = namespacePathString.find('/')) != std::string::npos)
|
||||
{
|
||||
namespacePath.push_back(std::string{namespacePathString.substr(0, loc)});
|
||||
namespacePath.emplace_back(std::string{namespacePathString.substr(0, loc)});
|
||||
namespacePathString = namespacePathString.substr(loc + 1);
|
||||
}
|
||||
namespacePath.push_back(std::string{namespacePathString});
|
||||
namespacePath.emplace_back(std::string{namespacePathString});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -178,7 +178,7 @@ static void trackRef(Ref* ref)
|
|||
AXASSERT(ref, "Invalid parameter, ref should not be null!");
|
||||
|
||||
// Create memory allocation record.
|
||||
__refAllocationList.push_back(ref);
|
||||
__refAllocationList.emplace_back(ref);
|
||||
}
|
||||
|
||||
static void untrackRef(Ref* ref)
|
||||
|
|
|
@ -557,7 +557,7 @@ void Scheduler::removeUpdateFromHash(struct _listEntry* entry)
|
|||
else
|
||||
{
|
||||
element->entry->markedForDeletion = true;
|
||||
_updateDeleteVector.push_back(element->entry);
|
||||
_updateDeleteVector.emplace_back(element->entry);
|
||||
}
|
||||
|
||||
// hash entry
|
||||
|
@ -815,7 +815,7 @@ void Scheduler::resumeTargets(const std::set<void*>& targetsToResume)
|
|||
void Scheduler::performFunctionInCocosThread(std::function<void()> function)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_performMutex);
|
||||
_functionsToPerform.push_back(std::move(function));
|
||||
_functionsToPerform.emplace_back(std::move(function));
|
||||
}
|
||||
|
||||
void Scheduler::removeAllFunctionsToBePerformedInCocosThread()
|
||||
|
|
|
@ -306,7 +306,7 @@ public:
|
|||
void pushBack(T object)
|
||||
{
|
||||
AXASSERT(object != nullptr, "The object should not be nullptr");
|
||||
_data.push_back(object);
|
||||
_data.emplace_back(object);
|
||||
object->retain();
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ public:
|
|||
{
|
||||
for (const auto& obj : other)
|
||||
{
|
||||
_data.push_back(obj);
|
||||
_data.emplace_back(obj);
|
||||
obj->retain();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,15 +39,15 @@ public:
|
|||
/** Const iterator, can be used to loop the Vector. */
|
||||
using const_iterator = typename std::deque<_Ty>::const_iterator;
|
||||
|
||||
void push_back(_Ty&& value)
|
||||
void emplace_back(_Ty&& value)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lck(this->mtx_);
|
||||
queue_.push_back(std::forward<_Ty>(value));
|
||||
queue_.emplace_back(std::forward<_Ty>(value));
|
||||
}
|
||||
void push_back(const _Ty& value)
|
||||
void emplace_back(const _Ty& value)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lck(this->mtx_);
|
||||
queue_.push_back(value);
|
||||
queue_.emplace_back(value);
|
||||
}
|
||||
_Ty& front()
|
||||
{
|
||||
|
@ -90,8 +90,8 @@ public:
|
|||
void lock() { this->mtx_.lock(); }
|
||||
void unlock() { this->mtx_.unlock(); }
|
||||
|
||||
void unsafe_push_back(_Ty&& value) { queue_.push_back(std::forward<_Ty>(value)); }
|
||||
void unsafe_push_back(const _Ty& value) { queue_.push_back(value); }
|
||||
void unsafe_emplace_back(_Ty&& value) { queue_.emplace_back(std::forward<_Ty>(value)); }
|
||||
void unsafe_emplace_back(const _Ty& value) { queue_.emplace_back(value); }
|
||||
_Ty& unsafe_front() { return queue_.front(); }
|
||||
void unsafe_pop_front() { queue_.pop_front(); }
|
||||
void unsafe_push_front(_Ty&& value) { queue_.push_font(std::forward<_Ty>(value)); }
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
int thread_count = std::thread::hardware_concurrency();
|
||||
for (int i = 0; i < thread_count; ++i)
|
||||
{
|
||||
_threads.push_back(std::thread{&astc_decompress_job_manager::run, this});
|
||||
_threads.emplace_back(std::thread{&astc_decompress_job_manager::run, this});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
return ASTCENC_ERR_OUT_OF_MEM;
|
||||
|
||||
_task_queue_mtx.lock();
|
||||
_task_queue.push_back(task);
|
||||
_task_queue.emplace_back(task);
|
||||
_task_queue_mtx.unlock();
|
||||
_task_queue_cv.notify_all(); // notify all thread to process the single decompress task parallel
|
||||
|
||||
|
|
|
@ -490,7 +490,7 @@ void StringUTF8::replace(std::string_view newStr)
|
|||
charUTF8._char.append((char*)sequenceUtf8, lengthChar);
|
||||
sequenceUtf8 += lengthChar;
|
||||
|
||||
_str.push_back(charUTF8);
|
||||
_str.emplace_back(charUTF8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,7 +204,7 @@ std::vector<Node*> findChildren(const Node& node, std::string_view name)
|
|||
std::vector<Node*> vec;
|
||||
|
||||
node.enumerateChildren(name, [&vec](Node* nodeFound) -> bool {
|
||||
vec.push_back(nodeFound);
|
||||
vec.emplace_back(nodeFound);
|
||||
return false;
|
||||
});
|
||||
|
||||
|
@ -673,7 +673,7 @@ std::vector<int> parseIntegerList(std::string_view intsString)
|
|||
errno = 0;
|
||||
AXLOGWARN("%s contains out of range integers", intsString.data());
|
||||
}
|
||||
result.push_back(static_cast<int>(i));
|
||||
result.emplace_back(static_cast<int>(i));
|
||||
cStr = endptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -543,7 +543,7 @@ void axis::NavMesh::findPath(const Vec3& start, const Vec3& end, std::vector<Vec
|
|||
// dtVcopy(&m_smoothPath[m_nsmoothPath * 3], iterPos);
|
||||
// m_nsmoothPath++;
|
||||
|
||||
pathPoints.push_back(Vec3(iterPos[0], iterPos[1], iterPos[2]));
|
||||
pathPoints.emplace_back(Vec3(iterPos[0], iterPos[1], iterPos[2]));
|
||||
nsmoothPath++;
|
||||
|
||||
// Move towards target a small advancement at a time until target reached or
|
||||
|
@ -597,7 +597,7 @@ void axis::NavMesh::findPath(const Vec3& start, const Vec3& end, std::vector<Vec
|
|||
{
|
||||
// dtVcopy(&m_smoothPath[m_nsmoothPath * 3], iterPos);
|
||||
// m_nsmoothPath++;
|
||||
pathPoints.push_back(Vec3(iterPos[0], iterPos[1], iterPos[2]));
|
||||
pathPoints.emplace_back(Vec3(iterPos[0], iterPos[1], iterPos[2]));
|
||||
nsmoothPath++;
|
||||
}
|
||||
break;
|
||||
|
@ -628,14 +628,14 @@ void axis::NavMesh::findPath(const Vec3& start, const Vec3& end, std::vector<Vec
|
|||
{
|
||||
// dtVcopy(&m_smoothPath[m_nsmoothPath * 3], startPos);
|
||||
// m_nsmoothPath++;
|
||||
pathPoints.push_back(Vec3(startPos[0], startPos[1], startPos[2]));
|
||||
pathPoints.emplace_back(Vec3(startPos[0], startPos[1], startPos[2]));
|
||||
nsmoothPath++;
|
||||
// Hack to make the dotted path not visible during off-mesh connection.
|
||||
if (nsmoothPath & 1)
|
||||
{
|
||||
// dtVcopy(&m_smoothPath[m_nsmoothPath * 3], startPos);
|
||||
// m_nsmoothPath++;
|
||||
pathPoints.push_back(Vec3(startPos[0], startPos[1], startPos[2]));
|
||||
pathPoints.emplace_back(Vec3(startPos[0], startPos[1], startPos[2]));
|
||||
nsmoothPath++;
|
||||
}
|
||||
}
|
||||
|
@ -653,7 +653,7 @@ void axis::NavMesh::findPath(const Vec3& start, const Vec3& end, std::vector<Vec
|
|||
// dtVcopy(&m_smoothPath[m_nsmoothPath * 3], iterPos);
|
||||
// m_nsmoothPath++;
|
||||
|
||||
pathPoints.push_back(Vec3(iterPos[0], iterPos[1], iterPos[2]));
|
||||
pathPoints.emplace_back(Vec3(iterPos[0], iterPos[1], iterPos[2]));
|
||||
nsmoothPath++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ void NavMeshDebugDraw::vertex(const float x, const float y, const float z, unsig
|
|||
if (!_currentPrimitive)
|
||||
return;
|
||||
V3F_C4F vertex = {Vec3(x, y, z), getColor(color)};
|
||||
_vertices.push_back(vertex);
|
||||
_vertices.emplace_back(vertex);
|
||||
_dirtyBuffer = true;
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ void NavMeshDebugDraw::end()
|
|||
if (!_currentPrimitive)
|
||||
return;
|
||||
_currentPrimitive->end = _vertices.size();
|
||||
_primitiveList.push_back(_currentPrimitive);
|
||||
_primitiveList.emplace_back(_currentPrimitive);
|
||||
_currentPrimitive = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -384,7 +384,7 @@ public:
|
|||
else
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_requestMutex);
|
||||
_requestQueue.push_back(task);
|
||||
_requestQueue.emplace_back(task);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -437,7 +437,7 @@ public:
|
|||
for (auto&& task : _processSet)
|
||||
{
|
||||
if (!task->background)
|
||||
outList.push_back(task);
|
||||
outList.emplace_back(task);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -824,7 +824,7 @@ private:
|
|||
else
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_finishedMutex);
|
||||
_finishedQueue.push_back(task);
|
||||
_finishedQueue.emplace_back(task);
|
||||
}
|
||||
}
|
||||
} while (m);
|
||||
|
|
|
@ -130,7 +130,7 @@ HttpClient::HttpClient()
|
|||
|
||||
for (int i = 0; i < HttpClient::MAX_CHANNELS; ++i)
|
||||
{
|
||||
_availChannelQueue.unsafe_push_back(i);
|
||||
_availChannelQueue.unsafe_emplace_back(i);
|
||||
}
|
||||
|
||||
_scheduler->schedule([=](float) { dispatchResponseCallbacks(); }, this, 0, false, "#");
|
||||
|
@ -235,7 +235,7 @@ void HttpClient::processResponse(HttpResponse* response, std::string_view url)
|
|||
}
|
||||
else
|
||||
{
|
||||
_pendingResponseQueue.push_back(response);
|
||||
_pendingResponseQueue.emplace_back(response);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,7 +468,7 @@ void HttpClient::finishResponse(HttpResponse* response)
|
|||
if (_dispatchOnWorkThread || std::this_thread::get_id() == Director::getInstance()->getCocos2dThreadId())
|
||||
invokeResposneCallbackAndRelease(response);
|
||||
else
|
||||
_finishedResponseQueue.push_back(response);
|
||||
_finishedResponseQueue.emplace_back(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -91,7 +91,7 @@ void HttpCookie::readFile()
|
|||
++count;
|
||||
});
|
||||
if (count >= 7)
|
||||
_cookies.push_back(std::move(cookieInfo));
|
||||
_cookies.emplace_back(std::move(cookieInfo));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ void HttpCookie::updateOrAddCookie(CookieInfo* cookie)
|
|||
return;
|
||||
}
|
||||
}
|
||||
_cookies.push_back(std::move(*cookie));
|
||||
_cookies.emplace_back(std::move(*cookie));
|
||||
}
|
||||
|
||||
std::string HttpCookie::checkAndGetFormatedMatchCookies(const Uri& uri)
|
||||
|
|
|
@ -154,8 +154,8 @@ bool PhysicsJoint::init(axis::PhysicsBody* a, axis::PhysicsBody* b)
|
|||
|
||||
_bodyA = a;
|
||||
_bodyB = b;
|
||||
_bodyA->_joints.push_back(this);
|
||||
_bodyB->_joints.push_back(this);
|
||||
_bodyA->_joints.emplace_back(this);
|
||||
_bodyB->_joints.emplace_back(this);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
@ -275,12 +275,12 @@ bool PhysicsJointFixed::createConstraints()
|
|||
// add a pivot joint to fixed two body together
|
||||
auto joint = cpPivotJointNew(_bodyA->getCPBody(), _bodyB->getCPBody(), PhysicsHelper::vec22cpv(_anchr));
|
||||
AX_BREAK_IF(joint == nullptr);
|
||||
_cpConstraints.push_back(joint);
|
||||
_cpConstraints.emplace_back(joint);
|
||||
|
||||
// add a gear joint to make two body have the same rotation.
|
||||
joint = cpGearJointNew(_bodyA->getCPBody(), _bodyB->getCPBody(), 0, 1);
|
||||
AX_BREAK_IF(joint == nullptr);
|
||||
_cpConstraints.push_back(joint);
|
||||
_cpConstraints.emplace_back(joint);
|
||||
|
||||
_collisionEnable = false;
|
||||
|
||||
|
@ -338,7 +338,7 @@ bool PhysicsJointPin::createConstraints()
|
|||
}
|
||||
|
||||
AX_BREAK_IF(joint == nullptr);
|
||||
_cpConstraints.push_back(joint);
|
||||
_cpConstraints.emplace_back(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
@ -382,7 +382,7 @@ bool PhysicsJointLimit::createConstraints()
|
|||
PhysicsHelper::vec22cpv(_anchr2), _min, _max);
|
||||
|
||||
AX_BREAK_IF(joint == nullptr);
|
||||
_cpConstraints.push_back(joint);
|
||||
_cpConstraints.emplace_back(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
@ -460,7 +460,7 @@ bool PhysicsJointDistance::createConstraints()
|
|||
auto joint = cpPinJointNew(_bodyA->getCPBody(), _bodyB->getCPBody(), PhysicsHelper::vec22cpv(_anchr1),
|
||||
PhysicsHelper::vec22cpv(_anchr2));
|
||||
AX_BREAK_IF(joint == nullptr);
|
||||
_cpConstraints.push_back(joint);
|
||||
_cpConstraints.emplace_back(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
@ -512,7 +512,7 @@ bool PhysicsJointSpring::createConstraints()
|
|||
_stiffness, _damping);
|
||||
|
||||
AX_BREAK_IF(joint == nullptr);
|
||||
_cpConstraints.push_back(joint);
|
||||
_cpConstraints.emplace_back(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
@ -604,7 +604,7 @@ bool PhysicsJointGroove::createConstraints()
|
|||
PhysicsHelper::vec22cpv(_grooveB), PhysicsHelper::vec22cpv(_anchr2));
|
||||
|
||||
AX_BREAK_IF(joint == nullptr);
|
||||
_cpConstraints.push_back(joint);
|
||||
_cpConstraints.emplace_back(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
@ -672,7 +672,7 @@ bool PhysicsJointRotarySpring::createConstraints()
|
|||
_bodyB->getRotation() - _bodyA->getRotation(), _stiffness, _damping);
|
||||
|
||||
AX_BREAK_IF(joint == nullptr);
|
||||
_cpConstraints.push_back(joint);
|
||||
_cpConstraints.emplace_back(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
@ -741,7 +741,7 @@ bool PhysicsJointRotaryLimit::createConstraints()
|
|||
auto joint = cpRotaryLimitJointNew(_bodyA->getCPBody(), _bodyB->getCPBody(), _min, _max);
|
||||
|
||||
AX_BREAK_IF(joint == nullptr);
|
||||
_cpConstraints.push_back(joint);
|
||||
_cpConstraints.emplace_back(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
@ -795,7 +795,7 @@ bool PhysicsJointRatchet::createConstraints()
|
|||
cpRatchetJointNew(_bodyA->getCPBody(), _bodyB->getCPBody(), _phase, PhysicsHelper::cpfloat2float(_ratchet));
|
||||
|
||||
AX_BREAK_IF(joint == nullptr);
|
||||
_cpConstraints.push_back(joint);
|
||||
_cpConstraints.emplace_back(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
@ -859,7 +859,7 @@ bool PhysicsJointGear::createConstraints()
|
|||
auto joint = cpGearJointNew(_bodyA->getCPBody(), _bodyB->getCPBody(), _phase, _ratio);
|
||||
|
||||
AX_BREAK_IF(joint == nullptr);
|
||||
_cpConstraints.push_back(joint);
|
||||
_cpConstraints.emplace_back(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
@ -911,7 +911,7 @@ bool PhysicsJointMotor::createConstraints()
|
|||
auto joint = cpSimpleMotorNew(_bodyA->getCPBody(), _bodyB->getCPBody(), _rate);
|
||||
|
||||
AX_BREAK_IF(joint == nullptr);
|
||||
_cpConstraints.push_back(joint);
|
||||
_cpConstraints.emplace_back(joint);
|
||||
|
||||
return true;
|
||||
} while (false);
|
||||
|
|
|
@ -113,7 +113,7 @@ protected:
|
|||
|
||||
bool initJoint();
|
||||
|
||||
void delay(const DelayTask& task) { _delayTasks.push_back(task); }
|
||||
void delay(const DelayTask& task) { _delayTasks.emplace_back(task); }
|
||||
|
||||
void flushDelayTasks();
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ void PhysicsShape::addShape(cpShape* shape)
|
|||
{
|
||||
cpShapeSetUserData(shape, this);
|
||||
cpShapeSetFilter(shape, cpShapeFilterNew(_group, CP_ALL_CATEGORIES, CP_ALL_CATEGORIES));
|
||||
_cpShapes.push_back(shape);
|
||||
_cpShapes.emplace_back(shape);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -699,7 +699,7 @@ void PhysicsWorld::removeJoint(PhysicsJoint* joint, bool destroy)
|
|||
return;
|
||||
if (std::find(_delayRemoveJoints.rbegin(), _delayRemoveJoints.rend(), joint) == _delayRemoveJoints.rend())
|
||||
{
|
||||
_delayRemoveJoints.push_back(joint);
|
||||
_delayRemoveJoints.emplace_back(joint);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -721,7 +721,7 @@ void PhysicsWorld::updateJoints()
|
|||
joint->_world = this;
|
||||
if (joint->initJoint())
|
||||
{
|
||||
_joints.push_back(joint);
|
||||
_joints.emplace_back(joint);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -772,7 +772,7 @@ void PhysicsWorld::addJoint(PhysicsJoint* joint)
|
|||
|
||||
if (std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint) == _delayAddJoints.end())
|
||||
{
|
||||
_delayAddJoints.push_back(joint);
|
||||
_delayAddJoints.emplace_back(joint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ void Physics3DRigidBody::addConstraint(Physics3DConstraint* constraint)
|
|||
auto iter = std::find(_constraintList.begin(), _constraintList.end(), constraint);
|
||||
if (iter == _constraintList.end())
|
||||
{
|
||||
_constraintList.push_back(constraint);
|
||||
_constraintList.emplace_back(constraint);
|
||||
constraint->retain();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ bool Physics3DShape::initCompoundShape(const std::vector<std::pair<Physics3DShap
|
|||
{
|
||||
compound->addChildShape(convertMat4TobtTransform(iter.second), iter.first->getbtShape());
|
||||
AX_SAFE_RETAIN(iter.first);
|
||||
_compoundChildShapes.push_back(iter.first);
|
||||
_compoundChildShapes.emplace_back(iter.first);
|
||||
}
|
||||
_btShape = compound;
|
||||
return true;
|
||||
|
|
|
@ -129,7 +129,7 @@ void Physics3DWorld::addPhysics3DObject(Physics3DObject* physicsObj)
|
|||
auto it = std::find(_objects.begin(), _objects.end(), physicsObj);
|
||||
if (it == _objects.end())
|
||||
{
|
||||
_objects.push_back(physicsObj);
|
||||
_objects.emplace_back(physicsObj);
|
||||
physicsObj->retain();
|
||||
if (physicsObj->getObjType() == Physics3DObject::PhysicsObjType::RIGID_BODY)
|
||||
{
|
||||
|
@ -200,7 +200,7 @@ void Physics3DWorld::addPhysics3DConstraint(Physics3DConstraint* constraint, boo
|
|||
}
|
||||
_btPhyiscsWorld->addConstraint(constraint->getbtContraint(), disableCollisionsBetweenLinkedObjs);
|
||||
|
||||
_constraints.push_back(constraint);
|
||||
_constraints.emplace_back(constraint);
|
||||
constraint->retain();
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ void Physics3DWorld::collisionChecking()
|
|||
convertbtVector3ToVec3(pt.m_localPointA), convertbtVector3ToVec3(pt.m_positionWorldOnA),
|
||||
convertbtVector3ToVec3(pt.m_localPointB), convertbtVector3ToVec3(pt.m_positionWorldOnB),
|
||||
convertbtVector3ToVec3(pt.m_normalWorldOnB)};
|
||||
ci.collisionPointList.push_back(cp);
|
||||
ci.collisionPointList.emplace_back(cp);
|
||||
}
|
||||
|
||||
if (poA->needCollisionCallback())
|
||||
|
|
|
@ -169,7 +169,7 @@ public:
|
|||
if (SAX_ARRAY == preState)
|
||||
{
|
||||
// add a new dictionary into the array
|
||||
_curArray->push_back(Value(ValueMap()));
|
||||
_curArray->emplace_back(Value(ValueMap()));
|
||||
_curDict = &(_curArray->rbegin())->asValueMap();
|
||||
}
|
||||
else if (SAX_DICT == preState)
|
||||
|
@ -224,7 +224,7 @@ public:
|
|||
{
|
||||
AXASSERT(!_arrayStack.empty(), "The state is wrong!");
|
||||
ValueVector* preArray = _arrayStack.top();
|
||||
preArray->push_back(Value(ValueVector()));
|
||||
preArray->emplace_back(Value(ValueVector()));
|
||||
_curArray = &(_curArray->rbegin())->asValueVector();
|
||||
}
|
||||
// record the array state
|
||||
|
@ -263,7 +263,7 @@ public:
|
|||
{
|
||||
if (SAX_ARRAY == curState)
|
||||
{
|
||||
_curArray->push_back(Value(true));
|
||||
_curArray->emplace_back(Value(true));
|
||||
}
|
||||
else if (SAX_DICT == curState)
|
||||
{
|
||||
|
@ -274,7 +274,7 @@ public:
|
|||
{
|
||||
if (SAX_ARRAY == curState)
|
||||
{
|
||||
_curArray->push_back(Value(false));
|
||||
_curArray->emplace_back(Value(false));
|
||||
}
|
||||
else if (SAX_DICT == curState)
|
||||
{
|
||||
|
@ -286,11 +286,11 @@ public:
|
|||
if (SAX_ARRAY == curState)
|
||||
{
|
||||
if (sName == "string"sv)
|
||||
_curArray->push_back(Value(_curValue));
|
||||
_curArray->emplace_back(Value(_curValue));
|
||||
else if (sName == "integer"sv)
|
||||
_curArray->push_back(Value(atoi(_curValue.c_str())));
|
||||
_curArray->emplace_back(Value(atoi(_curValue.c_str())));
|
||||
else
|
||||
_curArray->push_back(Value(std::atof(_curValue.c_str())));
|
||||
_curArray->emplace_back(Value(std::atof(_curValue.c_str())));
|
||||
}
|
||||
else if (SAX_DICT == curState)
|
||||
{
|
||||
|
@ -531,7 +531,7 @@ bool FileUtils::writeBinaryToFile(const void* data, size_t dataSize, std::string
|
|||
bool FileUtils::init()
|
||||
{
|
||||
DECLARE_GUARD;
|
||||
_searchPathArray.push_back(_defaultResRootPath);
|
||||
_searchPathArray.emplace_back(_defaultResRootPath);
|
||||
_searchResolutionsOrderArray.emplace_back("");
|
||||
return true;
|
||||
}
|
||||
|
@ -801,12 +801,12 @@ void FileUtils::setSearchResolutionsOrder(const std::vector<std::string>& search
|
|||
resolutionDirectory += "/";
|
||||
}
|
||||
|
||||
_searchResolutionsOrderArray.push_back(resolutionDirectory);
|
||||
_searchResolutionsOrderArray.emplace_back(resolutionDirectory);
|
||||
}
|
||||
|
||||
if (!existDefault)
|
||||
{
|
||||
_searchResolutionsOrderArray.push_back("");
|
||||
_searchResolutionsOrderArray.emplace_back("");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -825,7 +825,7 @@ void FileUtils::addSearchResolutionsOrder(std::string_view order, const bool fro
|
|||
}
|
||||
else
|
||||
{
|
||||
_searchResolutionsOrderArray.push_back(resOrder);
|
||||
_searchResolutionsOrderArray.emplace_back(resOrder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -905,13 +905,13 @@ void FileUtils::setSearchPaths(const std::vector<std::string>& searchPaths)
|
|||
{
|
||||
existDefaultRootPath = true;
|
||||
}
|
||||
_searchPathArray.push_back(fullPath);
|
||||
_searchPathArray.emplace_back(fullPath);
|
||||
}
|
||||
|
||||
if (!existDefaultRootPath)
|
||||
{
|
||||
// AXLOG("Default root path doesn't exist, adding it.");
|
||||
_searchPathArray.push_back(_defaultResRootPath);
|
||||
_searchPathArray.emplace_back(_defaultResRootPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -935,8 +935,8 @@ void FileUtils::addSearchPath(std::string_view searchpath, const bool front)
|
|||
}
|
||||
else
|
||||
{
|
||||
_originalSearchPaths.push_back(std::string{searchpath});
|
||||
_searchPathArray.push_back(std::move(path));
|
||||
_originalSearchPaths.emplace_back(std::string{searchpath});
|
||||
_searchPathArray.emplace_back(std::move(path));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1261,14 +1261,14 @@ bool FileUtils::createDirectory(std::string_view path) const
|
|||
{
|
||||
subpath = path.substr(start, found - start + 1);
|
||||
if (!subpath.empty())
|
||||
dirs.push_back(std::string{subpath});
|
||||
dirs.emplace_back(std::string{subpath});
|
||||
start = found + 1;
|
||||
found = path.find_first_of("/\\", start);
|
||||
if (found == std::string::npos)
|
||||
{
|
||||
if (start < path.length())
|
||||
{
|
||||
dirs.push_back(std::string{path.substr(start)});
|
||||
dirs.emplace_back(std::string{path.substr(start)});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ static std::vector<Touch*> getAllTouchesVector()
|
|||
{
|
||||
if (temp & 0x00000001)
|
||||
{
|
||||
ret.push_back(g_touches[i]);
|
||||
ret.emplace_back(g_touches[i]);
|
||||
}
|
||||
temp >>= 1;
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ void GLView::handleTouchesBegin(int num, intptr_t ids[], float xs[], float ys[])
|
|||
AXLOGINFO("x = %f y = %f", touch->getLocationInView().x, touch->getLocationInView().y);
|
||||
|
||||
g_touchIdReorderMap.emplace(id, unusedIndex);
|
||||
touchEvent._touches.push_back(touch);
|
||||
touchEvent._touches.emplace_back(touch);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ void GLView::handleTouchesMove(int num, intptr_t ids[], float xs[], float ys[],
|
|||
touch->setTouchInfo(iter->second, (x - _viewPortRect.origin.x) / _scaleX,
|
||||
(y - _viewPortRect.origin.y) / _scaleY, force, maxForce);
|
||||
|
||||
touchEvent._touches.push_back(touch);
|
||||
touchEvent._touches.emplace_back(touch);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -428,7 +428,7 @@ void GLView::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode,
|
|||
touch->setTouchInfo(iter->second, (x - _viewPortRect.origin.x) / _scaleX,
|
||||
(y - _viewPortRect.origin.y) / _scaleY);
|
||||
|
||||
touchEvent._touches.push_back(touch);
|
||||
touchEvent._touches.emplace_back(touch);
|
||||
|
||||
g_touches[iter->second] = nullptr;
|
||||
removeUsedIndexBit(iter->second);
|
||||
|
|
|
@ -47,13 +47,13 @@ public:
|
|||
_curEleName = xsxml::string_view(name, size);
|
||||
};
|
||||
_sax3Handler.xml_attr_cb = [=](const char* name, size_t, const char* value, size_t) {
|
||||
_curEleAttrs.push_back(name);
|
||||
_curEleAttrs.push_back(value);
|
||||
_curEleAttrs.emplace_back(name);
|
||||
_curEleAttrs.emplace_back(value);
|
||||
};
|
||||
_sax3Handler.xml_end_attr_cb = [=]() {
|
||||
if (!_curEleAttrs.empty())
|
||||
{
|
||||
_curEleAttrs.push_back(nullptr);
|
||||
_curEleAttrs.emplace_back(nullptr);
|
||||
SAXParser::startElement(_ccsaxParserImp, (const AX_XML_CHAR*)_curEleName.c_str(),
|
||||
(const AX_XML_CHAR**)&_curEleAttrs[0]);
|
||||
_curEleAttrs.clear();
|
||||
|
|
|
@ -297,7 +297,7 @@ std::vector<std::string> FileUtilsAndroid::listFiles(std::string_view dirPath) c
|
|||
string filepath(tmpDir);
|
||||
if (isDirectoryExistInternal(filepath))
|
||||
filepath += "/";
|
||||
fileList.push_back(fullPath + filepath);
|
||||
fileList.emplace_back(fullPath + filepath);
|
||||
}
|
||||
AAssetDir_close(dir);
|
||||
return fileList;
|
||||
|
|
|
@ -314,7 +314,7 @@ std::string JniHelper::jstring2string(jstring jstr)
|
|||
jstring JniHelper::convert(LocalRefMapType& localRefs, axis::JniMethodInfo& t, const char* x)
|
||||
{
|
||||
jstring ret = axis::StringUtils::newStringUTFJNI(t.env, x ? x : "");
|
||||
localRefs[t.env].push_back(ret);
|
||||
localRefs[t.env].emplace_back(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -609,7 +609,7 @@ void GLViewImpl::setIcon(const std::vector<std::string_view>& filelist) const
|
|||
Image* icon = new Image();
|
||||
if (icon->initWithImageFile(filename))
|
||||
{
|
||||
icons.push_back(icon);
|
||||
icons.emplace_back(icon);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -203,7 +203,7 @@ public:
|
|||
{
|
||||
currentLine.calculateWidth();
|
||||
iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth);
|
||||
textLines.push_back(currentLine);
|
||||
textLines.emplace_back(currentLine);
|
||||
currentLine.reset();
|
||||
prevGlyphIndex = 0;
|
||||
prevCharacter = 0;
|
||||
|
@ -277,7 +277,7 @@ public:
|
|||
}
|
||||
currentLine.calculateWidth();
|
||||
iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth);
|
||||
textLines.push_back(currentLine);
|
||||
textLines.emplace_back(currentLine);
|
||||
currentLine.reset();
|
||||
currentPaintPosition = 0;
|
||||
for (auto& glyph : tempGlyphs)
|
||||
|
@ -288,7 +288,7 @@ public:
|
|||
glyph.kerning = 0;
|
||||
}
|
||||
glyph.paintPosition = currentPaintPosition + glyph.bearingX + glyph.kerning;
|
||||
currentLine.glyphs.push_back(glyph);
|
||||
currentLine.glyphs.emplace_back(glyph);
|
||||
currentPaintPosition += glyph.kerning + glyph.horizAdvance;
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ public:
|
|||
glyph.kerning = 0;
|
||||
currentLine.calculateWidth();
|
||||
iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth);
|
||||
textLines.push_back(currentLine);
|
||||
textLines.emplace_back(currentLine);
|
||||
currentLine.reset();
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ public:
|
|||
currentPaintPosition = -glyph.bearingX;
|
||||
}
|
||||
glyph.paintPosition = currentPaintPosition + glyph.bearingX + glyph.kerning;
|
||||
currentLine.glyphs.push_back(glyph);
|
||||
currentLine.glyphs.emplace_back(glyph);
|
||||
currentPaintPosition += glyph.kerning + glyph.horizAdvance;
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ public:
|
|||
{
|
||||
currentLine.calculateWidth();
|
||||
iMaxLineWidth = max(iMaxLineWidth, currentLine.lineWidth);
|
||||
textLines.push_back(currentLine);
|
||||
textLines.emplace_back(currentLine);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -339,14 +339,14 @@ bool FileUtilsWin32::createDirectory(std::string_view dirPath) const
|
|||
{
|
||||
subpath = path.substr(start, found - start + 1);
|
||||
if (!subpath.empty())
|
||||
dirs.push_back(subpath);
|
||||
dirs.emplace_back(subpath);
|
||||
start = found + 1;
|
||||
found = path.find_first_of(L"/\\", start);
|
||||
if (found == std::wstring::npos)
|
||||
{
|
||||
if (start < path.length())
|
||||
{
|
||||
dirs.push_back(path.substr(start));
|
||||
dirs.emplace_back(path.substr(start));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ int GroupCommandManager::getGroupID()
|
|||
void GroupCommandManager::releaseGroupID(int groupID)
|
||||
{
|
||||
_groupMapping[groupID] = false;
|
||||
_unusedIDs.push_back(groupID);
|
||||
_unusedIDs.emplace_back(groupID);
|
||||
}
|
||||
|
||||
GroupCommand::GroupCommand()
|
||||
|
|
|
@ -63,7 +63,7 @@ void QuadCommand::reIndex(int indicesCount)
|
|||
|
||||
AXLOG("cocos2d: QuadCommand: resizing index size from [%d] to [%d]", __indexCapacity, indicesCount);
|
||||
|
||||
_ownedIndices.push_back(__indices);
|
||||
_ownedIndices.emplace_back(__indices);
|
||||
__indices = new uint16_t[indicesCount];
|
||||
__indexCapacity = indicesCount;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
// return;
|
||||
// }
|
||||
|
||||
_freePool.push_back(ptr);
|
||||
_freePool.emplace_back(ptr);
|
||||
//_usedPool.erase(ptr);
|
||||
}
|
||||
|
||||
|
@ -83,10 +83,10 @@ private:
|
|||
{
|
||||
static const int COMMANDS_ALLOCATE_BLOCK_SIZE = 32;
|
||||
T* commands = new T[COMMANDS_ALLOCATE_BLOCK_SIZE];
|
||||
_allocatedPoolBlocks.push_back(commands);
|
||||
_allocatedPoolBlocks.emplace_back(commands);
|
||||
for (int index = 0; index < COMMANDS_ALLOCATE_BLOCK_SIZE; ++index)
|
||||
{
|
||||
_freePool.push_back(commands + index);
|
||||
_freePool.emplace_back(commands + index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,16 +66,16 @@ static bool compare3DCommand(RenderCommand* a, RenderCommand* b)
|
|||
// queue
|
||||
RenderQueue::RenderQueue() {}
|
||||
|
||||
void RenderQueue::push_back(RenderCommand* command)
|
||||
void RenderQueue::emplace_back(RenderCommand* command)
|
||||
{
|
||||
float z = command->getGlobalOrder();
|
||||
if (z < 0)
|
||||
{
|
||||
_commands[QUEUE_GROUP::GLOBALZ_NEG].push_back(command);
|
||||
_commands[QUEUE_GROUP::GLOBALZ_NEG].emplace_back(command);
|
||||
}
|
||||
else if (z > 0)
|
||||
{
|
||||
_commands[QUEUE_GROUP::GLOBALZ_POS].push_back(command);
|
||||
_commands[QUEUE_GROUP::GLOBALZ_POS].emplace_back(command);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -83,16 +83,16 @@ void RenderQueue::push_back(RenderCommand* command)
|
|||
{
|
||||
if (command->isTransparent())
|
||||
{
|
||||
_commands[QUEUE_GROUP::TRANSPARENT_3D].push_back(command);
|
||||
_commands[QUEUE_GROUP::TRANSPARENT_3D].emplace_back(command);
|
||||
}
|
||||
else
|
||||
{
|
||||
_commands[QUEUE_GROUP::OPAQUE_3D].push_back(command);
|
||||
_commands[QUEUE_GROUP::OPAQUE_3D].emplace_back(command);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_commands[QUEUE_GROUP::GLOBALZ_ZERO].push_back(command);
|
||||
_commands[QUEUE_GROUP::GLOBALZ_ZERO].emplace_back(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ Renderer::Renderer()
|
|||
_commandGroupStack.push(DEFAULT_RENDER_QUEUE);
|
||||
|
||||
RenderQueue defaultRenderQueue;
|
||||
_renderGroups.push_back(defaultRenderQueue);
|
||||
_renderGroups.emplace_back(defaultRenderQueue);
|
||||
_queuedTriangleCommands.reserve(BATCH_TRIAGCOMMAND_RESERVED_SIZE);
|
||||
|
||||
// for the batched TriangleCommand
|
||||
|
@ -238,7 +238,7 @@ void Renderer::addCommand(RenderCommand* command, int renderQueueID)
|
|||
AXASSERT(renderQueueID >= 0, "Invalid render queue");
|
||||
AXASSERT(command->getType() != RenderCommand::Type::UNKNOWN_COMMAND, "Invalid Command Type");
|
||||
|
||||
_renderGroups[renderQueueID].push_back(command);
|
||||
_renderGroups[renderQueueID].emplace_back(command);
|
||||
}
|
||||
|
||||
void Renderer::pushGroup(int renderQueueID)
|
||||
|
@ -256,7 +256,7 @@ void Renderer::popGroup()
|
|||
int Renderer::createRenderQueue()
|
||||
{
|
||||
RenderQueue newRenderQueue;
|
||||
_renderGroups.push_back(newRenderQueue);
|
||||
_renderGroups.emplace_back(newRenderQueue);
|
||||
return (int)_renderGroups.size() - 1;
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ void Renderer::processRenderCommand(RenderCommand* command)
|
|||
}
|
||||
|
||||
// queue it
|
||||
_queuedTriangleCommands.push_back(cmd);
|
||||
_queuedTriangleCommands.emplace_back(cmd);
|
||||
#ifdef AX_USE_METAL
|
||||
_queuedIndexCount += cmd->getIndexCount();
|
||||
_queuedVertexCount += cmd->getVertexCount();
|
||||
|
@ -330,7 +330,7 @@ void Renderer::processRenderCommand(RenderCommand* command)
|
|||
case RenderCommand::Type::CALLBACK_COMMAND:
|
||||
flush();
|
||||
static_cast<CallbackCommand*>(command)->execute();
|
||||
_callbackCommandsPool.push_back(static_cast<CallbackCommand*>(command));
|
||||
_callbackCommandsPool.emplace_back(static_cast<CallbackCommand*>(command));
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
|
@ -1017,8 +1017,8 @@ void Renderer::TriangleCommandBufferManager::createBuffer()
|
|||
free(tmpData);
|
||||
#endif
|
||||
|
||||
_vertexBufferPool.push_back(vertexBuffer);
|
||||
_indexBufferPool.push_back(indexBuffer);
|
||||
_vertexBufferPool.emplace_back(vertexBuffer);
|
||||
_indexBufferPool.emplace_back(indexBuffer);
|
||||
}
|
||||
|
||||
void Renderer::pushStateBlock()
|
||||
|
|
|
@ -92,7 +92,7 @@ public:
|
|||
/**Constructor.*/
|
||||
RenderQueue();
|
||||
/**Push a renderCommand into current renderqueue.*/
|
||||
void push_back(RenderCommand* command);
|
||||
void emplace_back(RenderCommand* command);
|
||||
/**Return the number of render commands.*/
|
||||
ssize_t size() const;
|
||||
/**Sort the render commands.*/
|
||||
|
|
|
@ -218,9 +218,9 @@ void TextureCache::addImageAsync(std::string_view path,
|
|||
AsyncStruct* data = new AsyncStruct(fullpath, callback, callbackKey);
|
||||
|
||||
// add async struct into queue
|
||||
_asyncStructQueue.push_back(data);
|
||||
_asyncStructQueue.emplace_back(data);
|
||||
std::unique_lock<std::mutex> ul(_requestMutex);
|
||||
_requestQueue.push_back(data);
|
||||
_requestQueue.emplace_back(data);
|
||||
_sleepCondition.notify_one();
|
||||
}
|
||||
|
||||
|
@ -293,7 +293,7 @@ void TextureCache::loadImage()
|
|||
}
|
||||
// push the asyncStruct to response queue
|
||||
_responseMutex.lock();
|
||||
_responseQueue.push_back(asyncStruct);
|
||||
_responseQueue.emplace_back(asyncStruct);
|
||||
_responseMutex.unlock();
|
||||
}
|
||||
}
|
||||
|
@ -774,7 +774,7 @@ VolatileTexture* VolatileTextureMgr::findVolotileTexture(Texture2D* tt)
|
|||
if (!vt)
|
||||
{
|
||||
vt = new VolatileTexture(tt);
|
||||
_textures.push_back(vt);
|
||||
_textures.emplace_back(vt);
|
||||
}
|
||||
|
||||
return vt;
|
||||
|
|
|
@ -895,7 +895,7 @@ void MyXMLVisitor::textHandler(void* /*ctx*/, const char* str, size_t len)
|
|||
|
||||
void MyXMLVisitor::pushBackFontElement(const MyXMLVisitor::Attributes& attribs)
|
||||
{
|
||||
_fontElements.push_back(attribs);
|
||||
_fontElements.emplace_back(attribs);
|
||||
}
|
||||
|
||||
void MyXMLVisitor::popBackFontElement()
|
||||
|
|
|
@ -947,10 +947,10 @@ void ScrollView::gatherTouchMove(const Vec2& delta)
|
|||
_touchMoveDisplacements.pop_front();
|
||||
_touchMoveTimeDeltas.pop_front();
|
||||
}
|
||||
_touchMoveDisplacements.push_back(delta);
|
||||
_touchMoveDisplacements.emplace_back(delta);
|
||||
|
||||
long long timestamp = utils::getTimeInMilliseconds();
|
||||
_touchMoveTimeDeltas.push_back((timestamp - _touchMovePreviousTimestamp) / 1000.0f);
|
||||
_touchMoveTimeDeltas.emplace_back((timestamp - _touchMovePreviousTimestamp) / 1000.0f);
|
||||
_touchMovePreviousTimestamp = timestamp;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,19 +99,19 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
|
||||
if (screenSize.height > 320)
|
||||
{
|
||||
searchPaths.push_back("hd");
|
||||
searchPaths.push_back("ccs-res/hd");
|
||||
searchPaths.push_back("ccs-res");
|
||||
searchPaths.push_back("Manifests");
|
||||
searchPaths.emplace_back("hd");
|
||||
searchPaths.emplace_back("ccs-res/hd");
|
||||
searchPaths.emplace_back("ccs-res");
|
||||
searchPaths.emplace_back("Manifests");
|
||||
director->setContentScaleFactor(resourceSize.height / designSize.height);
|
||||
|
||||
searchPaths.push_back("hd/ActionTimeline");
|
||||
searchPaths.emplace_back("hd/ActionTimeline");
|
||||
}
|
||||
else
|
||||
{
|
||||
searchPaths.push_back("ccs-res");
|
||||
searchPaths.emplace_back("ccs-res");
|
||||
|
||||
searchPaths.push_back("ActionTimeline");
|
||||
searchPaths.emplace_back("ActionTimeline");
|
||||
}
|
||||
|
||||
fileUtils->setSearchPaths(searchPaths);
|
||||
|
|
|
@ -133,7 +133,7 @@ BillBoardTest::BillBoardTest() : _camera(nullptr)
|
|||
billboard->setScale(0.5f);
|
||||
billboard->setPosition3D(Vec3(0.0f, 0.0f, rand_minus1_1() * 150.0f));
|
||||
billboard->setOpacity(static_cast<uint8_t>(AXRANDOM_0_1() * 128 + 128));
|
||||
_billboards.push_back(billboard);
|
||||
_billboards.emplace_back(billboard);
|
||||
layer->addChild(billboard);
|
||||
_layerBillBoard->addChild(layer);
|
||||
layer->runAction(RepeatForever::create(RotateBy::create(AXRANDOM_0_1() * 10, Vec3(0.0f, 45.0f, 0.0f))));
|
||||
|
@ -147,8 +147,8 @@ BillBoardTest::BillBoardTest() : _camera(nullptr)
|
|||
auto billboard2 = BillBoard::create("Images/r2.png");
|
||||
billboard2->setPosition3D(Vec3(0.0f, 0.0f, 100.0f));
|
||||
billboard->addChild(billboard2);
|
||||
_billboards.push_back(billboard);
|
||||
_billboards.push_back(billboard2);
|
||||
_billboards.emplace_back(billboard);
|
||||
_billboards.emplace_back(billboard2);
|
||||
|
||||
auto mesh = MeshRenderer::create("MeshRendererTest/orc.c3t");
|
||||
mesh->setScale(2.0f);
|
||||
|
@ -241,7 +241,7 @@ void BillBoardTest::addNewBillBoardWithCoords(Vec3 p)
|
|||
billboard->setOpacity(static_cast<uint8_t>(AXRANDOM_0_1() * 128 + 128));
|
||||
|
||||
_layerBillBoard->addChild(billboard);
|
||||
_billboards.push_back(billboard);
|
||||
_billboards.emplace_back(billboard);
|
||||
}
|
||||
}
|
||||
void BillBoardTest::addNewAniBillBoardWithCoords(Vec3 p)
|
||||
|
@ -267,7 +267,7 @@ void BillBoardTest::addNewAniBillBoardWithCoords(Vec3 p)
|
|||
auto action = Animate::create(animation);
|
||||
billboardAni->runAction(RepeatForever::create(action));
|
||||
billboardAni->setOpacity(static_cast<uint8_t>(AXRANDOM_0_1() * 128 + 128));
|
||||
_billboards.push_back(billboardAni);
|
||||
_billboards.emplace_back(billboardAni);
|
||||
}
|
||||
}
|
||||
void BillBoardTest::update(float dt) {}
|
||||
|
|
|
@ -886,7 +886,7 @@ void CameraCullingDemo::addMeshCallback(Ref* sender)
|
|||
auto sprite = MeshRenderer::create("MeshRendererTest/orc.c3b");
|
||||
sprite->setPosition3D(Vec3(x * 30.0f, 0.0f, z * 30.0f));
|
||||
sprite->setRotation3D(Vec3(0.0f, 180.0f, 0.0f));
|
||||
_objects.push_back(sprite);
|
||||
_objects.emplace_back(sprite);
|
||||
_layer3D->addChild(sprite);
|
||||
}
|
||||
}
|
||||
|
@ -915,7 +915,7 @@ void CameraCullingDemo::delMeshCallback(Ref* sender)
|
|||
{
|
||||
auto sprite = MeshRenderer::create("MeshRendererTest/orc.c3b");
|
||||
sprite->setPosition3D(Vec3(x * 30.0f, 0.0f, z * 30.0f));
|
||||
_objects.push_back(sprite);
|
||||
_objects.emplace_back(sprite);
|
||||
_layer3D->addChild(sprite);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -828,7 +828,7 @@ void ClippingToRenderTextureTest::setup()
|
|||
auto button = MenuItemFont::create("Reproduce bug", [&](Ref* sender) {
|
||||
std::vector<Node*> nodes;
|
||||
enumerateChildren("remove me [0-9]", [&](Node* node) {
|
||||
nodes.push_back(node);
|
||||
nodes.emplace_back(node);
|
||||
return false;
|
||||
});
|
||||
for (auto node : nodes)
|
||||
|
|
|
@ -692,8 +692,8 @@ void TestWriteValueMap::onEnter()
|
|||
valueMap["data1"] = Value("string in array");
|
||||
|
||||
ValueVector arrayInMap;
|
||||
arrayInMap.push_back(Value("string 0 in arrayInMap"));
|
||||
arrayInMap.push_back(Value("string 1 in arrayInMap"));
|
||||
arrayInMap.emplace_back(Value("string 0 in arrayInMap"));
|
||||
arrayInMap.emplace_back(Value("string 1 in arrayInMap"));
|
||||
valueMap["data2"] = arrayInMap;
|
||||
|
||||
// add boolean to the plist
|
||||
|
@ -789,30 +789,30 @@ void TestWriteValueVector::onEnter()
|
|||
ValueMap mapInArray;
|
||||
mapInArray["string1"] = "string in dictInArray key 0";
|
||||
mapInArray["string2"] = "string in dictInArray key 1";
|
||||
array.push_back(Value(mapInArray));
|
||||
array.emplace_back(Value(mapInArray));
|
||||
|
||||
array.push_back(Value("string in array"));
|
||||
array.emplace_back(Value("string in array"));
|
||||
|
||||
ValueVector arrayInArray;
|
||||
arrayInArray.push_back(Value("string 0 in arrayInArray"));
|
||||
arrayInArray.push_back(Value("string 1 in arrayInArray"));
|
||||
array.push_back(Value(arrayInArray));
|
||||
arrayInArray.emplace_back(Value("string 0 in arrayInArray"));
|
||||
arrayInArray.emplace_back(Value("string 1 in arrayInArray"));
|
||||
array.emplace_back(Value(arrayInArray));
|
||||
|
||||
// add boolean to the plist
|
||||
auto booleanObject = Value(true);
|
||||
array.push_back(booleanObject);
|
||||
array.emplace_back(booleanObject);
|
||||
|
||||
// add integer to the plist
|
||||
auto intObject = Value(1024);
|
||||
array.push_back(intObject);
|
||||
array.emplace_back(intObject);
|
||||
|
||||
// add float to the plist
|
||||
auto floatObject = Value(1024.1024f);
|
||||
array.push_back(floatObject);
|
||||
array.emplace_back(floatObject);
|
||||
|
||||
// add double to the plist
|
||||
auto doubleObject = Value(1024.123);
|
||||
array.push_back(doubleObject);
|
||||
array.emplace_back(doubleObject);
|
||||
|
||||
// end with /
|
||||
std::string writablePath = FileUtils::getInstance()->getWritablePath();
|
||||
|
|
|
@ -621,9 +621,9 @@ bool LabelFNTMultiLineAlignment::init()
|
|||
lineBreaks->setTag(LineBreaks);
|
||||
mixed->setTag(Mixed);
|
||||
|
||||
_menuItems.push_back(longSentences);
|
||||
_menuItems.push_back(lineBreaks);
|
||||
_menuItems.push_back(mixed);
|
||||
_menuItems.emplace_back(longSentences);
|
||||
_menuItems.emplace_back(lineBreaks);
|
||||
_menuItems.emplace_back(mixed);
|
||||
|
||||
MenuItemFont::setFontSize(30);
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ void DrawNode3D::drawLine(const Vec3& from, const Vec3& to, const Color4F& color
|
|||
col,
|
||||
};
|
||||
|
||||
_bufferLines.push_back(a);
|
||||
_bufferLines.push_back(b);
|
||||
_bufferLines.emplace_back(a);
|
||||
_bufferLines.emplace_back(b);
|
||||
|
||||
_isDirty = true;
|
||||
}
|
||||
|
|
|
@ -800,7 +800,7 @@ void MeshRendererEffectTest::addNewMeshWithCoords(Vec2 p)
|
|||
auto seq = Sequence::create(action, action_back, nullptr);
|
||||
|
||||
mesh->runAction(RepeatForever::create(seq));
|
||||
_meshes.push_back(mesh);
|
||||
_meshes.emplace_back(mesh);
|
||||
}
|
||||
|
||||
void MeshRendererEffectTest::onTouchesEnded(const std::vector<Touch*>& touches, Event* event)
|
||||
|
@ -815,10 +815,10 @@ void MeshRendererEffectTest::onTouchesEnded(const std::vector<Touch*>& touches,
|
|||
|
||||
AsyncLoadMeshRendererTest::AsyncLoadMeshRendererTest()
|
||||
{
|
||||
_paths.push_back("MeshRendererTest/girl.c3b");
|
||||
_paths.push_back("MeshRendererTest/orc.c3b");
|
||||
_paths.push_back("MeshRendererTest/ReskinGirl.c3b");
|
||||
_paths.push_back("MeshRendererTest/axe.c3b");
|
||||
_paths.emplace_back("MeshRendererTest/girl.c3b");
|
||||
_paths.emplace_back("MeshRendererTest/orc.c3b");
|
||||
_paths.emplace_back("MeshRendererTest/ReskinGirl.c3b");
|
||||
_paths.emplace_back("MeshRendererTest/axe.c3b");
|
||||
|
||||
TTFConfig ttfConfig("fonts/arial.ttf", 15);
|
||||
auto label1 = Label::createWithTTF(ttfConfig, "AsyncLoad MeshRenderer");
|
||||
|
@ -919,7 +919,7 @@ void MeshRendererWithSkinTest::addNewMeshWithCoords(Vec2 p)
|
|||
mesh->setRotation3D(Vec3(0.0f, 180.0f, 0.0f));
|
||||
mesh->setPosition(Vec2(p.x, p.y));
|
||||
addChild(mesh);
|
||||
_meshes.push_back(mesh);
|
||||
_meshes.emplace_back(mesh);
|
||||
|
||||
auto animation = Animation3D::create(fileName);
|
||||
if (animation)
|
||||
|
@ -1328,32 +1328,32 @@ void MeshRendererReskinTest::addNewMeshWithCoords(Vec2 p)
|
|||
_mesh = mesh;
|
||||
|
||||
auto& body = _skins[(int)SkinType::UPPER_BODY];
|
||||
body.push_back("Girl_UpperBody01");
|
||||
body.push_back("Girl_UpperBody02");
|
||||
body.emplace_back("Girl_UpperBody01");
|
||||
body.emplace_back("Girl_UpperBody02");
|
||||
|
||||
auto& pants = _skins[(int)SkinType::PANTS];
|
||||
pants.push_back("Girl_LowerBody01");
|
||||
pants.push_back("Girl_LowerBody02");
|
||||
pants.emplace_back("Girl_LowerBody01");
|
||||
pants.emplace_back("Girl_LowerBody02");
|
||||
|
||||
auto& shoes = _skins[(int)SkinType::SHOES];
|
||||
shoes.push_back("Girl_Shoes01");
|
||||
shoes.push_back("Girl_Shoes02");
|
||||
shoes.emplace_back("Girl_Shoes01");
|
||||
shoes.emplace_back("Girl_Shoes02");
|
||||
|
||||
auto& hair = _skins[(int)SkinType::HAIR];
|
||||
hair.push_back("Girl_Hair01");
|
||||
hair.push_back("Girl_Hair02");
|
||||
hair.emplace_back("Girl_Hair01");
|
||||
hair.emplace_back("Girl_Hair02");
|
||||
|
||||
auto& face = _skins[(int)SkinType::FACE];
|
||||
face.push_back("Girl_Face01");
|
||||
face.push_back("Girl_Face02");
|
||||
face.emplace_back("Girl_Face01");
|
||||
face.emplace_back("Girl_Face02");
|
||||
|
||||
auto& hand = _skins[(int)SkinType::HAND];
|
||||
hand.push_back("Girl_Hand01");
|
||||
hand.push_back("Girl_Hand02");
|
||||
hand.emplace_back("Girl_Hand01");
|
||||
hand.emplace_back("Girl_Hand02");
|
||||
|
||||
auto& glasses = _skins[(int)SkinType::GLASSES];
|
||||
glasses.push_back("");
|
||||
glasses.push_back("Girl_Glasses01");
|
||||
glasses.emplace_back("");
|
||||
glasses.emplace_back("Girl_Glasses01");
|
||||
|
||||
memset(_curSkin, 0, (int)SkinType::MAX_TYPE * sizeof(int));
|
||||
|
||||
|
@ -1426,7 +1426,7 @@ void MeshRendererWithOBBPerformanceTest::addNewOBBWithCoords(Vec2 p)
|
|||
AABB aabb(-extents, extents);
|
||||
auto obb = OBB(aabb);
|
||||
obb._center = Vec3(p.x, p.y, 0);
|
||||
_obb.push_back(obb);
|
||||
_obb.emplace_back(obb);
|
||||
}
|
||||
|
||||
void MeshRendererWithOBBPerformanceTest::onTouchesBegan(const std::vector<Touch*>& touches, Event* event)
|
||||
|
@ -1569,7 +1569,7 @@ void MeshRendererWithOBBPerformanceTest::addOBBWithCount(float value)
|
|||
AABB aabb(-extents, extents);
|
||||
auto obb = OBB(aabb);
|
||||
obb._center = Vec3(randompos.x, randompos.y, 0);
|
||||
_obb.push_back(obb);
|
||||
_obb.emplace_back(obb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1992,7 +1992,7 @@ void NodeAnimationTest::addNewMeshWithCoords(Vec2 p)
|
|||
mesh->runAction(act);
|
||||
}
|
||||
addChild(mesh);
|
||||
_meshes.push_back(mesh);
|
||||
_meshes.emplace_back(mesh);
|
||||
|
||||
// add jumping orc
|
||||
fileName = "MeshRendererTest/orc_jump.c3t";
|
||||
|
@ -2010,7 +2010,7 @@ void NodeAnimationTest::addNewMeshWithCoords(Vec2 p)
|
|||
mesh->runAction(act);
|
||||
}
|
||||
addChild(mesh);
|
||||
_meshes.push_back(mesh);
|
||||
_meshes.emplace_back(mesh);
|
||||
}
|
||||
|
||||
MeshRendererCubeMapTest::MeshRendererCubeMapTest() : _textureCube(nullptr), _skyBox(nullptr), _teapot(nullptr)
|
||||
|
|
|
@ -195,7 +195,7 @@ void NavMeshBaseTestDemo::createAgent(const Vec3& pos)
|
|||
animate->setSpeed(0);
|
||||
}
|
||||
|
||||
_agents.push_back(std::make_pair(agent, animate));
|
||||
_agents.emplace_back(std::make_pair(agent, animate));
|
||||
}
|
||||
|
||||
void NavMeshBaseTestDemo::createObstacle(const Vec3& pos)
|
||||
|
|
|
@ -254,7 +254,7 @@ void HttpClientTest::onMenuPutTestClicked(Ref* sender)
|
|||
request->setUrl("https://httpbin.org/put");
|
||||
request->setRequestType(HttpRequest::Type::PUT);
|
||||
std::vector<std::string> headers;
|
||||
headers.push_back("Content-Type: application/json; charset=utf-8");
|
||||
headers.emplace_back("Content-Type: application/json; charset=utf-8");
|
||||
request->setHeaders(headers);
|
||||
request->setResponseCallback(AX_CALLBACK_2(HttpClientTest::onHttpRequestCompleted, this));
|
||||
|
||||
|
|
|
@ -1205,7 +1205,7 @@ void AudioPlayInFinishedCB::doPlay(std::string_view filename)
|
|||
|
||||
void AudioPlayInFinishedCB::playMusic(std::string_view filename)
|
||||
{
|
||||
_playList.push_back(std::string{filename});
|
||||
_playList.emplace_back(std::string{filename});
|
||||
if (_playList.size() == 1)
|
||||
{
|
||||
doPlay(filename);
|
||||
|
|
|
@ -511,7 +511,7 @@ void SpriteCreation::doTest()
|
|||
delete sprite;
|
||||
break;
|
||||
}
|
||||
spriteCache.push_back(sprite);
|
||||
spriteCache.emplace_back(sprite);
|
||||
}
|
||||
|
||||
auto creationDuration = perf.endTick(KEY_CREATION);
|
||||
|
|
|
@ -647,22 +647,22 @@ bool Physics3DTerrainDemo::init()
|
|||
Mat4 localTrans;
|
||||
auto bodyshape = Physics3DShape::createBox(Vec3(2.0f, 4.0f, 2.0f));
|
||||
Mat4::createTranslation(0.0f, 2.0f, 0.0f, &localTrans);
|
||||
shapeList.push_back(std::make_pair(bodyshape, localTrans));
|
||||
shapeList.emplace_back(std::make_pair(bodyshape, localTrans));
|
||||
auto headshape = Physics3DShape::createSphere(1.5f);
|
||||
Mat4::createTranslation(0.6f, 5.0f, -1.5f, &localTrans);
|
||||
shapeList.push_back(std::make_pair(headshape, localTrans));
|
||||
shapeList.emplace_back(std::make_pair(headshape, localTrans));
|
||||
auto lhandshape = Physics3DShape::createBox(Vec3(1.0f, 3.0f, 1.0f));
|
||||
Mat4::createRotation(Vec3(1.0f, 0.0f, 0.0f), AX_DEGREES_TO_RADIANS(15.0f), &localTrans);
|
||||
localTrans.m[12] = -1.5f;
|
||||
localTrans.m[13] = 2.5f;
|
||||
localTrans.m[14] = -2.5f;
|
||||
shapeList.push_back(std::make_pair(lhandshape, localTrans));
|
||||
shapeList.emplace_back(std::make_pair(lhandshape, localTrans));
|
||||
auto rhandshape = Physics3DShape::createBox(Vec3(1.0f, 3.0f, 1.0f));
|
||||
Mat4::createRotation(Vec3(1.0f, 0.0f, 0.0f), AX_DEGREES_TO_RADIANS(-15.0f), &localTrans);
|
||||
localTrans.m[12] = 2.0f;
|
||||
localTrans.m[13] = 2.5f;
|
||||
localTrans.m[14] = 1.f;
|
||||
shapeList.push_back(std::make_pair(rhandshape, localTrans));
|
||||
shapeList.emplace_back(std::make_pair(rhandshape, localTrans));
|
||||
|
||||
rbDes.mass = 10.0f;
|
||||
rbDes.shape = Physics3DShape::createCompoundShape(shapeList);
|
||||
|
|
|
@ -757,32 +757,32 @@ void Scene3DTestScene::createDescDlg()
|
|||
}
|
||||
|
||||
auto& body = _skins[(int)SkinType::UPPER_BODY];
|
||||
body.push_back("Girl_UpperBody01");
|
||||
body.push_back("Girl_UpperBody02");
|
||||
body.emplace_back("Girl_UpperBody01");
|
||||
body.emplace_back("Girl_UpperBody02");
|
||||
|
||||
auto& pants = _skins[(int)SkinType::PANTS];
|
||||
pants.push_back("Girl_LowerBody01");
|
||||
pants.push_back("Girl_LowerBody02");
|
||||
pants.emplace_back("Girl_LowerBody01");
|
||||
pants.emplace_back("Girl_LowerBody02");
|
||||
|
||||
auto& shoes = _skins[(int)SkinType::SHOES];
|
||||
shoes.push_back("Girl_Shoes01");
|
||||
shoes.push_back("Girl_Shoes02");
|
||||
shoes.emplace_back("Girl_Shoes01");
|
||||
shoes.emplace_back("Girl_Shoes02");
|
||||
|
||||
auto& hair = _skins[(int)SkinType::HAIR];
|
||||
hair.push_back("Girl_Hair01");
|
||||
hair.push_back("Girl_Hair02");
|
||||
hair.emplace_back("Girl_Hair01");
|
||||
hair.emplace_back("Girl_Hair02");
|
||||
|
||||
auto& face = _skins[(int)SkinType::FACE];
|
||||
face.push_back("Girl_Face01");
|
||||
face.push_back("Girl_Face02");
|
||||
face.emplace_back("Girl_Face01");
|
||||
face.emplace_back("Girl_Face02");
|
||||
|
||||
auto& hand = _skins[(int)SkinType::HAND];
|
||||
hand.push_back("Girl_Hand01");
|
||||
hand.push_back("Girl_Hand02");
|
||||
hand.emplace_back("Girl_Hand01");
|
||||
hand.emplace_back("Girl_Hand02");
|
||||
|
||||
auto& glasses = _skins[(int)SkinType::GLASSES];
|
||||
glasses.push_back("");
|
||||
glasses.push_back("Girl_Glasses01");
|
||||
glasses.emplace_back("");
|
||||
glasses.emplace_back("Girl_Glasses01");
|
||||
|
||||
memset(_curSkin, 0, (int)SkinType::MAX_TYPE * sizeof(int));
|
||||
|
||||
|
|
|
@ -1367,7 +1367,7 @@ void SchedulerRemoveEntryWhileUpdate::onEnter()
|
|||
nextObj = _testvector[i - 1];
|
||||
}
|
||||
auto obj = new TestClass(i, nextObj, getScheduler());
|
||||
_testvector.push_back(obj);
|
||||
_testvector.emplace_back(obj);
|
||||
getScheduler()->scheduleUpdate(obj, 500 - i, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
effect->retain();
|
||||
effect->setTarget(this);
|
||||
|
||||
_effects.push_back(std::make_tuple(order, effect, QuadCommand()));
|
||||
_effects.emplace_back(std::make_tuple(order, effect, QuadCommand()));
|
||||
|
||||
std::sort(std::begin(_effects), std::end(_effects), tuple_sort);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ bool UIListViewTest_Vertical::init()
|
|||
for (int i = 0; i < _totalCount; ++i)
|
||||
{
|
||||
std::string ccstr = StringUtils::format("listview_item_%d", i);
|
||||
_array.push_back(ccstr);
|
||||
_array.emplace_back(ccstr);
|
||||
}
|
||||
|
||||
// Create the list view ex
|
||||
|
@ -329,7 +329,7 @@ bool UIListViewTest_Horizontal::init()
|
|||
for (int i = 0; i < _totalCount; ++i)
|
||||
{
|
||||
std::string ccstr = StringUtils::format("listview_item_%d", i);
|
||||
_array.push_back(ccstr);
|
||||
_array.emplace_back(ccstr);
|
||||
}
|
||||
|
||||
// Create the list view ex
|
||||
|
|
|
@ -511,9 +511,9 @@ void TemplateMapTest::onEnter()
|
|||
AXASSERT(mapForErase.size() == 18, "mapForErase's size is 18.");
|
||||
|
||||
std::vector<std::string> itemsToRemove;
|
||||
itemsToRemove.push_back("2");
|
||||
itemsToRemove.push_back("3");
|
||||
itemsToRemove.push_back("4");
|
||||
itemsToRemove.emplace_back("2");
|
||||
itemsToRemove.emplace_back("3");
|
||||
itemsToRemove.emplace_back("4");
|
||||
mapForErase.erase(itemsToRemove);
|
||||
AXASSERT(mapForErase.size() == 15, "mapForErase's size is 15.");
|
||||
|
||||
|
@ -612,9 +612,9 @@ void ValueTest::onEnter()
|
|||
|
||||
auto createValueVector = [&]() {
|
||||
ValueVector ret;
|
||||
ret.push_back(v1);
|
||||
ret.push_back(v2);
|
||||
ret.push_back(v3);
|
||||
ret.emplace_back(v1);
|
||||
ret.emplace_back(v2);
|
||||
ret.emplace_back(v3);
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
@ -710,10 +710,10 @@ static void doUTFConversion()
|
|||
|
||||
//---------------------------
|
||||
std::vector<char16_t> vec2(vec1);
|
||||
vec2.push_back(0x2009);
|
||||
vec2.push_back(0x2009);
|
||||
vec2.push_back(0x2009);
|
||||
vec2.push_back(0x2009);
|
||||
vec2.emplace_back(0x2009);
|
||||
vec2.emplace_back(0x2009);
|
||||
vec2.emplace_back(0x2009);
|
||||
vec2.emplace_back(0x2009);
|
||||
|
||||
std::vector<char16_t> vec3(vec2);
|
||||
StringUtils::trimUTF16Vector(vec2);
|
||||
|
|
|
@ -80,7 +80,7 @@ UserDefaultTest::UserDefaultTest()
|
|||
//
|
||||
// for (int i = 0; i <= 5; i++)
|
||||
// {
|
||||
// v.push_back(static_cast<T>(i));
|
||||
// v.emplace_back(static_cast<T>(i));
|
||||
// }
|
||||
// data.copy((unsigned char*) v.data(), v.size() * sizeof(T));
|
||||
// UserDefault::getInstance()->setDataForKey(key, data);
|
||||
|
@ -94,7 +94,7 @@ UserDefaultTest::UserDefaultTest()
|
|||
//
|
||||
// for (int i = 5; i >= 0; i--)
|
||||
// {
|
||||
// v.push_back(static_cast<T>(i));
|
||||
// v.emplace_back(static_cast<T>(i));
|
||||
// }
|
||||
// data.copy((unsigned char*) v.data(), v.size() * sizeof(T));
|
||||
// UserDefault::getInstance()->setDataForKey(key, data);
|
||||
|
|
Loading…
Reference in New Issue