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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d91aafa86970daba236dd2fb71955cacb14875a59015bbec7165dda09780a0e
4
- data.tar.gz: 3f9480090194bd2ebff61e80ddd0b85d81d2ce8f2a525f399ecbb84d5b714b0d
3
+ metadata.gz: 43c1c1c3d8ce4bc0609cb5311bbef76f77ba09b44620d8e3e50f60c82d0abc48
4
+ data.tar.gz: d8043f9c0249a92114b61dddd5f66b961c24ee391e612b41fdb394e5a7716506
5
5
  SHA512:
6
- metadata.gz: b09b1b2af1855653eab5228aa9327e7baca6d9e0ff7d2eac8787c34c67c0a2bccba49839ff1b07a0828a678afde379820abf2c4a4b36e645b35733a0cda0d87e
7
- data.tar.gz: 835349a8a40734e8d6b633a050cdfe4f7f104a5e86abd70fee0683b56935477bb615885167f65b709b1283a2ec73ff1c77981974363f850d3da17278efa25dd3
6
+ metadata.gz: 1217901dc2bb0e5d6ba710d1cc46fdad3de23d720a441c7537c33c07f97bb16e5fbf1a5ddca6c439bc35bc2f6647c1558e1125bfdc32512914bd6abe8b97859f
7
+ data.tar.gz: d55d2743baa53fc88f14f4d15609c6e8782280728d369f00495c5c77520052a617ea3f68647f1d96e5fd90c09e7dae36776a8c5f0f7a61f927c0bd55c11973dd
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tiny_obj (0.2.2)
4
+ tiny_obj (0.2.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
  }
@@ -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
@@ -416,21 +416,11 @@ extern "C" {
416
416
  return rb_colors;
417
417
  }
418
418
 
419
- VALUE rb_obj_to_hash(VALUE self) {
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));
@@ -1,3 +1,3 @@
1
1
  module TinyOBJ
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_obj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin MacKenzie IV