blender-3d 0.1.0 → 0.2.0

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
  SHA1:
3
- metadata.gz: 14b1b6b25b75bc3144579623d6ebaf1eb20ed295
4
- data.tar.gz: 94d505a329ebe729c2970ad9cf563829b365bcf4
3
+ metadata.gz: 3a057403b1d063c59505fb6cfcd7ac4c67640342
4
+ data.tar.gz: f2cd8a90be5652c54e7b7ee209d09729d5df7665
5
5
  SHA512:
6
- metadata.gz: b10f4977194b4c18d5790b7bcb2aaf2674404751bf0aa63843eaafbd6df47626ad5db875099e6a5f090f2e4e49a2b76258ed97ce84db43eb9fb5afa4ac1a491f
7
- data.tar.gz: 4eea3fb816ffb01d0fcf08e1a77a7ba7cad124a813dcc953b837bb7b7c2e64feba455f62635053fc3c033b0c7aec11f97a7014bcd1cd728c3885481ec2610e00
6
+ metadata.gz: 5aefe8b85d9f9b9d18ae496be42e4f73378dab00da0d0bfa853ae03449bad895a6c5ac0c36cae80f1bfdef77fa7ad8f79fd99123f8d201d83ce0f0a9675a47c2
7
+ data.tar.gz: 77774c2a3e201ed5f4a09fc72432478dc4e4866f9e9c17cd186877e91e1c74a2ef76fd5578b837e85857bfc36f32ca9cb41ab944fde422cb82350d1235e3e953
@@ -1,7 +1,7 @@
1
1
  module Blender3d
2
2
  class Model
3
3
  attr_reader :header, :blocks, :pointers
4
-
4
+
5
5
  def self.from_file(path)
6
6
  File.open(path, 'rb') { |file| new(file) }
7
7
  end
@@ -30,17 +30,7 @@ module Blender3d
30
30
  end
31
31
 
32
32
  @pointers = {}
33
- @blocks.each do |block|
34
- if block.data.is_a?(Array)
35
- pointer = block.pointer.location
36
- block.data.each do |data|
37
- @pointers[Pointer.new(pointer)] = data
38
- pointer += data.class.definition.size
39
- end
40
- else
41
- @pointers[block.pointer] = block.data
42
- end
43
- end
33
+ @blocks.each { |block| @pointers[block.pointer] = block.data }
44
34
 
45
35
  self
46
36
  end
@@ -23,5 +23,27 @@ module Blender3d
23
23
  def ==(other)
24
24
  (self <=> other) == 0
25
25
  end
26
+
27
+ def !=(other)
28
+ !(self == other)
29
+ end
30
+
31
+ def hash
32
+ @location.hash
33
+ end
34
+
35
+ def +(other)
36
+ return Pointer.new(@location + other) if other.is_a?(Integer)
37
+ raise TypeError, "#{other.class} cannot be implicitly converted into an Integer"
38
+ end
39
+
40
+ def -(other)
41
+ return Pointer.new(@location - other) if other.is_a?(Integer)
42
+ return @location - other.location if other.is_a?(Pointer)
43
+ raise TypeError, "#{other.class} cannot be implicitly converted into a Pointer"
44
+ end
45
+
46
+ alias_method :eql? , :==
47
+ alias_method :to_i , :location
26
48
  end
27
49
  end
@@ -1,3 +1,3 @@
1
1
  module Blender3d
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blender-3d
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SilverPhoenix99