mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-07-31 14:51:57 +08:00
Partial cleaning on cc files
This commit is contained in:
parent
9afc0d3177
commit
0f69ddffb1
@ -1,5 +1,3 @@
|
|||||||
// Copyright 2017 The Draco Authors.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@ -51,26 +49,34 @@ namespace draco {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void decode_normals(std::unique_ptr<draco::Mesh> &drc_mesh, Drc2PyMesh* out_mesh) {
|
||||||
int hello() {
|
const auto normal_att = drc_mesh->GetNamedAttribute(draco::GeometryAttribute::NORMAL);
|
||||||
return 20;
|
if (normal_att == nullptr) {
|
||||||
|
out_mesh->normals = new float[0];
|
||||||
|
out_mesh->normals_num = 0;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fill_int(int *num) {
|
int num_normals = drc_mesh->num_points();
|
||||||
*num = 1982;
|
out_mesh->normals = new float[num_normals];
|
||||||
|
out_mesh->normals_num = num_normals;
|
||||||
|
//out_mesh->has_normals = true;
|
||||||
|
|
||||||
|
for (int i = 0; i < num_normals; i++) {
|
||||||
|
draco::PointIndex pi(i);
|
||||||
|
const draco::AttributeValueIndex val_index = normal_att->mapped_index(pi);
|
||||||
|
|
||||||
|
float out_normal[3];
|
||||||
|
bool is_ok = normal_att->ConvertValue<float, 3>(val_index, out_normal);
|
||||||
|
if (!is_ok) return;
|
||||||
|
|
||||||
|
out_mesh->normals[i * 3 + 0] = out_normal[0];
|
||||||
|
out_mesh->normals[i * 3 + 1] = out_normal[1];
|
||||||
|
out_mesh->normals[i * 3 + 2] = out_normal[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
MyStruct* fill_mystruct() {
|
|
||||||
MyStruct* my = new MyStruct();
|
|
||||||
my->num_faces = 500;
|
|
||||||
return my;
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
void fill_mystruct2(MyStruct** my) {
|
|
||||||
*my = new MyStruct();
|
|
||||||
(*my)->num_faces = 900;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ReleaseMayaMesh(DracoToMayaMesh **mesh_ptr) {
|
void ReleaseMayaMesh(DracoToMayaMesh **mesh_ptr) {
|
||||||
DracoToMayaMesh *mesh = *mesh_ptr;
|
DracoToMayaMesh *mesh = *mesh_ptr;
|
||||||
if (!mesh)
|
if (!mesh)
|
||||||
@ -101,7 +107,7 @@ namespace draco {
|
|||||||
delete mesh;
|
delete mesh;
|
||||||
*mesh_ptr = nullptr;
|
*mesh_ptr = nullptr;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
int drc2py_decode(char *data, unsigned int length, Drc2PyMesh **res_mesh) {
|
int drc2py_decode(char *data, unsigned int length, Drc2PyMesh **res_mesh) {
|
||||||
draco::DecoderBuffer buffer;
|
draco::DecoderBuffer buffer;
|
||||||
buffer.Init(data, length);
|
buffer.Init(data, length);
|
||||||
@ -123,14 +129,12 @@ namespace draco {
|
|||||||
std::unique_ptr<draco::Mesh> drc_mesh = std::move(statusor).value();
|
std::unique_ptr<draco::Mesh> drc_mesh = std::move(statusor).value();
|
||||||
|
|
||||||
*res_mesh = new Drc2PyMesh();
|
*res_mesh = new Drc2PyMesh();
|
||||||
//(*res_mesh)->faces_num = drc_mesh->num_faces();
|
|
||||||
//(*res_mesh)->vertices_num = drc_mesh->num_points();
|
|
||||||
decode_faces(drc_mesh, *res_mesh);
|
decode_faces(drc_mesh, *res_mesh);
|
||||||
decode_vertices(drc_mesh, *res_mesh);
|
decode_vertices(drc_mesh, *res_mesh);
|
||||||
|
decode_normals(drc_mesh, *res_mesh);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
int DecodeMeshForMaya(char *data, unsigned int length, DracoToMayaMesh **tmp_mesh) {
|
int DecodeMeshForMaya(char *data, unsigned int length, DracoToMayaMesh **tmp_mesh) {
|
||||||
draco::DecoderBuffer buffer;
|
draco::DecoderBuffer buffer;
|
||||||
buffer.Init(data, length);
|
buffer.Init(data, length);
|
||||||
@ -224,7 +228,7 @@ namespace draco {
|
|||||||
|
|
||||||
return in_mesh->num_faces();
|
return in_mesh->num_faces();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
} // namespace maya
|
} // namespace maya
|
||||||
|
|
||||||
} // namespace draco
|
} // namespace draco
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// Copyright 2017 The Draco Authors.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@ -30,68 +28,26 @@
|
|||||||
|
|
||||||
namespace draco {
|
namespace draco {
|
||||||
namespace maya {
|
namespace maya {
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
struct EXPORT_API DracoToMayaMesh {
|
//void ReleaseMayaMesh(DracoToMayaMesh **mesh_ptr);
|
||||||
DracoToMayaMesh()
|
|
||||||
: num_faces(0),
|
|
||||||
indices(nullptr),
|
|
||||||
num_vertices(0),
|
|
||||||
position(nullptr),
|
|
||||||
has_normal(false),
|
|
||||||
normal(nullptr),
|
|
||||||
has_texcoord(false),
|
|
||||||
texcoord(nullptr),
|
|
||||||
has_color(false),
|
|
||||||
color(nullptr) {}
|
|
||||||
|
|
||||||
int num_faces;
|
|
||||||
int *indices;
|
|
||||||
int num_vertices;
|
|
||||||
float *position;
|
|
||||||
bool has_normal;
|
|
||||||
float *normal;
|
|
||||||
bool has_texcoord;
|
|
||||||
float *texcoord;
|
|
||||||
bool has_color;
|
|
||||||
float *color;
|
|
||||||
};
|
|
||||||
|
|
||||||
void ReleaseMayaMesh(DracoToMayaMesh **mesh_ptr);
|
|
||||||
|
|
||||||
/* To use this function, you do not allocate memory for |tmp_mesh|, just
|
|
||||||
* define and pass a null pointer. Otherwise there will be memory leak.
|
|
||||||
*/
|
|
||||||
int EXPORT_API DecodeMeshForMaya(char *data, unsigned int length, DracoToMayaMesh **tmp_mesh);
|
|
||||||
|
|
||||||
|
|
||||||
struct EXPORT_API Drc2PyMesh {
|
struct EXPORT_API Drc2PyMesh {
|
||||||
Drc2PyMesh()
|
Drc2PyMesh()
|
||||||
: faces_num(0),
|
: faces_num(0),
|
||||||
vertices_num(0) {}
|
faces(nullptr),
|
||||||
|
vertices_num(0),
|
||||||
|
vertices(nullptr),
|
||||||
|
normals_num(0),
|
||||||
|
normals(nullptr) {}
|
||||||
int faces_num;
|
int faces_num;
|
||||||
int* faces;
|
int* faces;
|
||||||
int vertices_num;
|
int vertices_num;
|
||||||
float* vertices;
|
float* vertices;
|
||||||
|
int normals_num;
|
||||||
|
float* normals;
|
||||||
};
|
};
|
||||||
|
|
||||||
EXPORT_API int drc2py_decode(char *data, unsigned int length, Drc2PyMesh **res_mesh);
|
EXPORT_API int drc2py_decode(char *data, unsigned int length, Drc2PyMesh **res_mesh);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct EXPORT_API MyStruct {
|
|
||||||
MyStruct()
|
|
||||||
: num_faces(0) {}
|
|
||||||
//indices(nullptr) {}
|
|
||||||
int num_faces;
|
|
||||||
//int *indices;
|
|
||||||
};
|
|
||||||
int EXPORT_API hello();
|
|
||||||
void EXPORT_API fill_int(int *num);
|
|
||||||
|
|
||||||
EXPORT_API MyStruct* fill_mystruct();
|
|
||||||
EXPORT_API void fill_mystruct2(MyStruct** my);
|
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
} // namespace maya
|
} // namespace maya
|
||||||
|
Loading…
x
Reference in New Issue
Block a user