change std::make_unique to mmd::make_unique
parent
ccf2bce2b0
commit
8cd0d3b3c7
|
@ -1,19 +1,20 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef MMD_CPP14_H
|
#ifndef MMD_CPP14_H
|
||||||
|
#define MMD_CPP14_H
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace std {
|
namespace mmd {
|
||||||
template<class T> struct _Unique_if {
|
template<class T> struct _Unique_if {
|
||||||
typedef unique_ptr<T> _Single_object;
|
typedef std::unique_ptr<T> _Single_object;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T> struct _Unique_if<T[]> {
|
template<class T> struct _Unique_if<T[]> {
|
||||||
typedef unique_ptr<T[]> _Unknown_bound;
|
typedef std::unique_ptr<T[]> _Unknown_bound;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T, size_t N> struct _Unique_if<T[N]> {
|
template<class T, size_t N> struct _Unique_if<T[N]> {
|
||||||
|
@ -23,14 +24,14 @@ namespace std {
|
||||||
template<class T, class... Args>
|
template<class T, class... Args>
|
||||||
typename _Unique_if<T>::_Single_object
|
typename _Unique_if<T>::_Single_object
|
||||||
make_unique(Args&&... args) {
|
make_unique(Args&&... args) {
|
||||||
return unique_ptr<T>(new T(std::forward<Args>(args)...));
|
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
typename _Unique_if<T>::_Unknown_bound
|
typename _Unique_if<T>::_Unknown_bound
|
||||||
make_unique(size_t n) {
|
make_unique(size_t n) {
|
||||||
typedef typename remove_extent<T>::type U;
|
typedef typename std::remove_extent<T>::type U;
|
||||||
return unique_ptr<T>(new U[n]());
|
return std::unique_ptr<T>(new U[n]());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class... Args>
|
template<class T, class... Args>
|
||||||
|
|
|
@ -454,7 +454,7 @@ namespace pmd
|
||||||
/// ファイルからPmdModelを生成する
|
/// ファイルからPmdModelを生成する
|
||||||
static std::unique_ptr<PmdModel> LoadFromStream(std::ifstream *stream)
|
static std::unique_ptr<PmdModel> LoadFromStream(std::ifstream *stream)
|
||||||
{
|
{
|
||||||
auto result = std::make_unique<PmdModel>();
|
auto result = mmd::make_unique<PmdModel>();
|
||||||
char buffer[100];
|
char buffer[100];
|
||||||
|
|
||||||
// magic
|
// magic
|
||||||
|
|
|
@ -163,19 +163,19 @@ namespace pmx
|
||||||
switch (this->skinning_type)
|
switch (this->skinning_type)
|
||||||
{
|
{
|
||||||
case PmxVertexSkinningType::BDEF1:
|
case PmxVertexSkinningType::BDEF1:
|
||||||
this->skinning = std::make_unique<PmxVertexSkinningBDEF1>();
|
this->skinning = mmd::make_unique<PmxVertexSkinningBDEF1>();
|
||||||
break;
|
break;
|
||||||
case PmxVertexSkinningType::BDEF2:
|
case PmxVertexSkinningType::BDEF2:
|
||||||
this->skinning = std::make_unique<PmxVertexSkinningBDEF2>();
|
this->skinning = mmd::make_unique<PmxVertexSkinningBDEF2>();
|
||||||
break;
|
break;
|
||||||
case PmxVertexSkinningType::BDEF4:
|
case PmxVertexSkinningType::BDEF4:
|
||||||
this->skinning = std::make_unique<PmxVertexSkinningBDEF4>();
|
this->skinning = mmd::make_unique<PmxVertexSkinningBDEF4>();
|
||||||
break;
|
break;
|
||||||
case PmxVertexSkinningType::SDEF:
|
case PmxVertexSkinningType::SDEF:
|
||||||
this->skinning = std::make_unique<PmxVertexSkinningSDEF>();
|
this->skinning = mmd::make_unique<PmxVertexSkinningSDEF>();
|
||||||
break;
|
break;
|
||||||
case PmxVertexSkinningType::QDEF:
|
case PmxVertexSkinningType::QDEF:
|
||||||
this->skinning = std::make_unique<PmxVertexSkinningQDEF>();
|
this->skinning = mmd::make_unique<PmxVertexSkinningQDEF>();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw "invalid skinning type";
|
throw "invalid skinning type";
|
||||||
|
@ -254,7 +254,7 @@ namespace pmx
|
||||||
stream->read((char*) &ik_loop, sizeof(int));
|
stream->read((char*) &ik_loop, sizeof(int));
|
||||||
stream->read((char*) &ik_loop_angle_limit, sizeof(float));
|
stream->read((char*) &ik_loop_angle_limit, sizeof(float));
|
||||||
stream->read((char*) &ik_link_count, sizeof(int));
|
stream->read((char*) &ik_link_count, sizeof(int));
|
||||||
this->ik_links = std::make_unique<PmxIkLink []>(ik_link_count);
|
this->ik_links = mmd::make_unique<PmxIkLink []>(ik_link_count);
|
||||||
for (int i = 0; i < ik_link_count; i++) {
|
for (int i = 0; i < ik_link_count; i++) {
|
||||||
ik_links[i].Read(stream, setting);
|
ik_links[i].Read(stream, setting);
|
||||||
}
|
}
|
||||||
|
@ -325,28 +325,28 @@ namespace pmx
|
||||||
switch (this->morph_type)
|
switch (this->morph_type)
|
||||||
{
|
{
|
||||||
case MorphType::Group:
|
case MorphType::Group:
|
||||||
group_offsets = std::make_unique<PmxMorphGroupOffset []>(this->offset_count);
|
group_offsets = mmd::make_unique<PmxMorphGroupOffset []>(this->offset_count);
|
||||||
for (int i = 0; i < offset_count; i++)
|
for (int i = 0; i < offset_count; i++)
|
||||||
{
|
{
|
||||||
group_offsets[i].Read(stream, setting);
|
group_offsets[i].Read(stream, setting);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MorphType::Vertex:
|
case MorphType::Vertex:
|
||||||
vertex_offsets = std::make_unique<PmxMorphVertexOffset []>(this->offset_count);
|
vertex_offsets = mmd::make_unique<PmxMorphVertexOffset []>(this->offset_count);
|
||||||
for (int i = 0; i < offset_count; i++)
|
for (int i = 0; i < offset_count; i++)
|
||||||
{
|
{
|
||||||
vertex_offsets[i].Read(stream, setting);
|
vertex_offsets[i].Read(stream, setting);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MorphType::Bone:
|
case MorphType::Bone:
|
||||||
bone_offsets = std::make_unique<PmxMorphBoneOffset []>(this->offset_count);
|
bone_offsets = mmd::make_unique<PmxMorphBoneOffset []>(this->offset_count);
|
||||||
for (int i = 0; i < offset_count; i++)
|
for (int i = 0; i < offset_count; i++)
|
||||||
{
|
{
|
||||||
bone_offsets[i].Read(stream, setting);
|
bone_offsets[i].Read(stream, setting);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MorphType::Matrial:
|
case MorphType::Matrial:
|
||||||
material_offsets = std::make_unique<PmxMorphMaterialOffset []>(this->offset_count);
|
material_offsets = mmd::make_unique<PmxMorphMaterialOffset []>(this->offset_count);
|
||||||
for (int i = 0; i < offset_count; i++)
|
for (int i = 0; i < offset_count; i++)
|
||||||
{
|
{
|
||||||
material_offsets[i].Read(stream, setting);
|
material_offsets[i].Read(stream, setting);
|
||||||
|
@ -357,7 +357,7 @@ namespace pmx
|
||||||
case MorphType::AdditionalUV2:
|
case MorphType::AdditionalUV2:
|
||||||
case MorphType::AdditionalUV3:
|
case MorphType::AdditionalUV3:
|
||||||
case MorphType::AdditionalUV4:
|
case MorphType::AdditionalUV4:
|
||||||
uv_offsets = std::make_unique<PmxMorphUVOffset []>(this->offset_count);
|
uv_offsets = mmd::make_unique<PmxMorphUVOffset []>(this->offset_count);
|
||||||
for (int i = 0; i < offset_count; i++)
|
for (int i = 0; i < offset_count; i++)
|
||||||
{
|
{
|
||||||
uv_offsets[i].Read(stream, setting);
|
uv_offsets[i].Read(stream, setting);
|
||||||
|
@ -386,7 +386,7 @@ namespace pmx
|
||||||
this->frame_english_name = ReadString(stream, setting->encoding);
|
this->frame_english_name = ReadString(stream, setting->encoding);
|
||||||
stream->read((char*) &this->frame_flag, sizeof(uint8_t));
|
stream->read((char*) &this->frame_flag, sizeof(uint8_t));
|
||||||
stream->read((char*) &this->element_count, sizeof(int));
|
stream->read((char*) &this->element_count, sizeof(int));
|
||||||
this->elements = std::make_unique<PmxFrameElement []>(this->element_count);
|
this->elements = mmd::make_unique<PmxFrameElement []>(this->element_count);
|
||||||
for (int i = 0; i < this->element_count; i++)
|
for (int i = 0; i < this->element_count; i++)
|
||||||
{
|
{
|
||||||
this->elements[i].Read(stream, setting);
|
this->elements[i].Read(stream, setting);
|
||||||
|
@ -505,7 +505,7 @@ namespace pmx
|
||||||
|
|
||||||
// 頂点
|
// 頂点
|
||||||
stream->read((char*) &vertex_count, sizeof(int));
|
stream->read((char*) &vertex_count, sizeof(int));
|
||||||
this->vertices = std::make_unique<PmxVertex []>(vertex_count);
|
this->vertices = mmd::make_unique<PmxVertex []>(vertex_count);
|
||||||
for (int i = 0; i < vertex_count; i++)
|
for (int i = 0; i < vertex_count; i++)
|
||||||
{
|
{
|
||||||
vertices[i].Read(stream, &setting);
|
vertices[i].Read(stream, &setting);
|
||||||
|
@ -513,7 +513,7 @@ namespace pmx
|
||||||
|
|
||||||
// 面
|
// 面
|
||||||
stream->read((char*) &index_count, sizeof(int));
|
stream->read((char*) &index_count, sizeof(int));
|
||||||
this->indices = std::make_unique<int []>(index_count);
|
this->indices = mmd::make_unique<int []>(index_count);
|
||||||
for (int i = 0; i < index_count; i++)
|
for (int i = 0; i < index_count; i++)
|
||||||
{
|
{
|
||||||
this->indices[i] = ReadIndex(stream, setting.vertex_index_size);
|
this->indices[i] = ReadIndex(stream, setting.vertex_index_size);
|
||||||
|
@ -521,7 +521,7 @@ namespace pmx
|
||||||
|
|
||||||
// テクスチャ
|
// テクスチャ
|
||||||
stream->read((char*) &texture_count, sizeof(int));
|
stream->read((char*) &texture_count, sizeof(int));
|
||||||
this->textures = std::make_unique<std::string []>(texture_count);
|
this->textures = mmd::make_unique<std::string []>(texture_count);
|
||||||
for (int i = 0; i < texture_count; i++)
|
for (int i = 0; i < texture_count; i++)
|
||||||
{
|
{
|
||||||
this->textures[i] = ReadString(stream, setting.encoding);
|
this->textures[i] = ReadString(stream, setting.encoding);
|
||||||
|
@ -529,7 +529,7 @@ namespace pmx
|
||||||
|
|
||||||
// マテリアル
|
// マテリアル
|
||||||
stream->read((char*) &material_count, sizeof(int));
|
stream->read((char*) &material_count, sizeof(int));
|
||||||
this->materials = std::make_unique<PmxMaterial []>(material_count);
|
this->materials = mmd::make_unique<PmxMaterial []>(material_count);
|
||||||
for (int i = 0; i < material_count; i++)
|
for (int i = 0; i < material_count; i++)
|
||||||
{
|
{
|
||||||
this->materials[i].Read(stream, &setting);
|
this->materials[i].Read(stream, &setting);
|
||||||
|
@ -537,7 +537,7 @@ namespace pmx
|
||||||
|
|
||||||
// ボーン
|
// ボーン
|
||||||
stream->read((char*) &this->bone_count, sizeof(int));
|
stream->read((char*) &this->bone_count, sizeof(int));
|
||||||
this->bones = std::make_unique<PmxBone []>(this->bone_count);
|
this->bones = mmd::make_unique<PmxBone []>(this->bone_count);
|
||||||
for (int i = 0; i < this->bone_count; i++)
|
for (int i = 0; i < this->bone_count; i++)
|
||||||
{
|
{
|
||||||
this->bones[i].Read(stream, &setting);
|
this->bones[i].Read(stream, &setting);
|
||||||
|
@ -545,7 +545,7 @@ namespace pmx
|
||||||
|
|
||||||
// モーフ
|
// モーフ
|
||||||
stream->read((char*) &this->morph_count, sizeof(int));
|
stream->read((char*) &this->morph_count, sizeof(int));
|
||||||
this->morphs = std::make_unique<PmxMorph []>(this->morph_count);
|
this->morphs = mmd::make_unique<PmxMorph []>(this->morph_count);
|
||||||
for (int i = 0; i < this->morph_count; i++)
|
for (int i = 0; i < this->morph_count; i++)
|
||||||
{
|
{
|
||||||
this->morphs[i].Read(stream, &setting);
|
this->morphs[i].Read(stream, &setting);
|
||||||
|
@ -553,7 +553,7 @@ namespace pmx
|
||||||
|
|
||||||
// 表示枠
|
// 表示枠
|
||||||
stream->read((char*) &this->frame_count, sizeof(int));
|
stream->read((char*) &this->frame_count, sizeof(int));
|
||||||
this->frames = std::make_unique<PmxFrame []>(this->frame_count);
|
this->frames = mmd::make_unique<PmxFrame []>(this->frame_count);
|
||||||
for (int i = 0; i < this->frame_count; i++)
|
for (int i = 0; i < this->frame_count; i++)
|
||||||
{
|
{
|
||||||
this->frames[i].Read(stream, &setting);
|
this->frames[i].Read(stream, &setting);
|
||||||
|
@ -561,7 +561,7 @@ namespace pmx
|
||||||
|
|
||||||
// 剛体
|
// 剛体
|
||||||
stream->read((char*) &this->rigid_body_count, sizeof(int));
|
stream->read((char*) &this->rigid_body_count, sizeof(int));
|
||||||
this->rigid_bodies = std::make_unique<PmxRigidBody []>(this->rigid_body_count);
|
this->rigid_bodies = mmd::make_unique<PmxRigidBody []>(this->rigid_body_count);
|
||||||
for (int i = 0; i < this->rigid_body_count; i++)
|
for (int i = 0; i < this->rigid_body_count; i++)
|
||||||
{
|
{
|
||||||
this->rigid_bodies[i].Read(stream, &setting);
|
this->rigid_bodies[i].Read(stream, &setting);
|
||||||
|
@ -569,7 +569,7 @@ namespace pmx
|
||||||
|
|
||||||
// ジョイント
|
// ジョイント
|
||||||
stream->read((char*) &this->joint_count, sizeof(int));
|
stream->read((char*) &this->joint_count, sizeof(int));
|
||||||
this->joints = std::make_unique<PmxJoint []>(this->joint_count);
|
this->joints = mmd::make_unique<PmxJoint []>(this->joint_count);
|
||||||
for (int i = 0; i < this->joint_count; i++)
|
for (int i = 0; i < this->joint_count; i++)
|
||||||
{
|
{
|
||||||
this->joints[i].Read(stream, &setting);
|
this->joints[i].Read(stream, &setting);
|
||||||
|
@ -579,7 +579,7 @@ namespace pmx
|
||||||
//if (this->version == 2.1f)
|
//if (this->version == 2.1f)
|
||||||
//{
|
//{
|
||||||
// stream->read((char*) &this->soft_body_count, sizeof(int));
|
// stream->read((char*) &this->soft_body_count, sizeof(int));
|
||||||
// this->soft_bodies = std::make_unique<PmxSoftBody []>(this->soft_body_count);
|
// this->soft_bodies = mmd::make_unique<PmxSoftBody []>(this->soft_body_count);
|
||||||
// for (int i = 0; i < this->soft_body_count; i++)
|
// for (int i = 0; i < this->soft_body_count; i++)
|
||||||
// {
|
// {
|
||||||
// this->soft_bodies[i].Read(stream, &setting);
|
// this->soft_bodies[i].Read(stream, &setting);
|
||||||
|
@ -601,7 +601,7 @@ namespace pmx
|
||||||
|
|
||||||
//std::unique_ptr<PmxModel> ReadFromStream(std::istream *stream)
|
//std::unique_ptr<PmxModel> ReadFromStream(std::istream *stream)
|
||||||
//{
|
//{
|
||||||
// auto pmx = std::make_unique<PmxModel>();
|
// auto pmx = mmd::make_unique<PmxModel>();
|
||||||
// pmx->Read(stream);
|
// pmx->Read(stream);
|
||||||
// return pmx;
|
// return pmx;
|
||||||
//}
|
//}
|
||||||
|
|
|
@ -220,7 +220,7 @@ namespace vmd
|
||||||
{
|
{
|
||||||
|
|
||||||
char buffer[30];
|
char buffer[30];
|
||||||
auto result = std::make_unique<VmdMotion>();
|
auto result = mmd::make_unique<VmdMotion>();
|
||||||
|
|
||||||
// magic and version
|
// magic and version
|
||||||
stream->read((char*) buffer, 30);
|
stream->read((char*) buffer, 30);
|
||||||
|
|
Loading…
Reference in New Issue