tiny_obj 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/ext/tiny_obj/init_tinyobj.c +1 -0
- data/ext/tiny_obj/rb_tinyobj.h +1 -0
- data/ext/tiny_obj/tinyobj.cpp +16 -11
- data/lib/tiny_obj/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43c1c1c3d8ce4bc0609cb5311bbef76f77ba09b44620d8e3e50f60c82d0abc48
|
4
|
+
data.tar.gz: d8043f9c0249a92114b61dddd5f66b961c24ee391e612b41fdb394e5a7716506
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1217901dc2bb0e5d6ba710d1cc46fdad3de23d720a441c7537c33c07f97bb16e5fbf1a5ddca6c439bc35bc2f6647c1558e1125bfdc32512914bd6abe8b97859f
|
7
|
+
data.tar.gz: d55d2743baa53fc88f14f4d15609c6e8782280728d369f00495c5c77520052a617ea3f68647f1d96e5fd90c09e7dae36776a8c5f0f7a61f927c0bd55c11973dd
|
data/Gemfile.lock
CHANGED
data/ext/tiny_obj/init_tinyobj.c
CHANGED
@@ -14,5 +14,6 @@ void Init_tiny_obj(void) {
|
|
14
14
|
rb_define_method(rb_cOBJ, "normals", rb_obj_normals, -1);
|
15
15
|
rb_define_method(rb_cOBJ, "texcoords", rb_obj_texcoords, -1);
|
16
16
|
rb_define_method(rb_cOBJ, "colors", rb_obj_colors, -1);
|
17
|
+
rb_define_method(rb_cOBJ, "materials", rb_obj_materials, 0);
|
17
18
|
rb_define_singleton_method(rb_mTinyOBJ, "load", rb_tinyobj_load, -1);
|
18
19
|
}
|
data/ext/tiny_obj/rb_tinyobj.h
CHANGED
@@ -16,6 +16,7 @@ extern "C" {
|
|
16
16
|
VALUE rb_obj_normals(int argc, VALUE *argv, VALUE self);
|
17
17
|
VALUE rb_obj_texcoords(int argc, VALUE *argv, VALUE self);
|
18
18
|
VALUE rb_obj_colors(int argc, VALUE *argv, VALUE self);
|
19
|
+
VALUE rb_obj_materials(VALUE self);
|
19
20
|
#ifdef __cplusplus
|
20
21
|
}
|
21
22
|
#endif
|
data/ext/tiny_obj/tinyobj.cpp
CHANGED
@@ -416,21 +416,11 @@ extern "C" {
|
|
416
416
|
return rb_colors;
|
417
417
|
}
|
418
418
|
|
419
|
-
VALUE
|
419
|
+
VALUE rb_obj_materials(VALUE self) {
|
420
420
|
obj_t *obj;
|
421
421
|
TypedData_Get_Struct(self, obj_t, &obj_type, obj);
|
422
|
-
std::string &warnings = *(obj->warnings);
|
423
|
-
std::vector<tinyobj::shape_t> &shapes = *(obj->shapes);
|
424
422
|
std::vector<tinyobj::material_t> &materials = *(obj->materials);
|
425
|
-
|
426
|
-
VALUE ret = rb_hash_new();
|
427
|
-
rb_hash_aset(ret, ID2SYM(rb_intern("success")), obj->result ? Qtrue : Qfalse);
|
428
|
-
|
429
|
-
if (warnings.size() > 0)
|
430
|
-
rb_hash_aset(ret, ID2SYM(rb_intern("warnings")), rb_str_new2(warnings.c_str()));
|
431
|
-
|
432
423
|
VALUE rb_materials = rb_ary_new2(materials.size());
|
433
|
-
rb_hash_aset(ret, ID2SYM(rb_intern("materials")), rb_materials);
|
434
424
|
for (size_t m = 0; m < materials.size(); m++) {
|
435
425
|
VALUE rb_material = rb_hash_new();
|
436
426
|
rb_ary_push(rb_materials, rb_material);
|
@@ -498,7 +488,22 @@ extern "C" {
|
|
498
488
|
if (!NIL_P(rb_unknown_parameter))
|
499
489
|
rb_hash_aset(rb_material, ID2SYM(rb_intern("unknown_parameters")), rb_unknown_parameter);
|
500
490
|
}
|
491
|
+
return rb_materials;
|
492
|
+
}
|
493
|
+
|
494
|
+
VALUE rb_obj_to_hash(VALUE self) {
|
495
|
+
obj_t *obj;
|
496
|
+
TypedData_Get_Struct(self, obj_t, &obj_type, obj);
|
497
|
+
std::string &warnings = *(obj->warnings);
|
498
|
+
std::vector<tinyobj::shape_t> &shapes = *(obj->shapes);
|
499
|
+
|
500
|
+
VALUE ret = rb_hash_new();
|
501
|
+
rb_hash_aset(ret, ID2SYM(rb_intern("success")), obj->result ? Qtrue : Qfalse);
|
502
|
+
|
503
|
+
if (warnings.size() > 0)
|
504
|
+
rb_hash_aset(ret, ID2SYM(rb_intern("warnings")), rb_str_new2(warnings.c_str()));
|
501
505
|
|
506
|
+
rb_hash_aset(ret, ID2SYM(rb_intern("materials")), rb_funcall(self, rb_intern("materials"), 0));
|
502
507
|
rb_hash_aset(ret, ID2SYM(rb_intern("vertices")), rb_funcall(self, rb_intern("vertices"), 0));
|
503
508
|
rb_hash_aset(ret, ID2SYM(rb_intern("normals")), rb_funcall(self, rb_intern("normals"), 0));
|
504
509
|
rb_hash_aset(ret, ID2SYM(rb_intern("texcoords")), rb_funcall(self, rb_intern("texcoords"), 0));
|
data/lib/tiny_obj/version.rb
CHANGED