blender-3d 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/blender-3d/model.rb +2 -12
- data/lib/blender-3d/pointer.rb +22 -0
- data/lib/blender-3d/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a057403b1d063c59505fb6cfcd7ac4c67640342
|
4
|
+
data.tar.gz: f2cd8a90be5652c54e7b7ee209d09729d5df7665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5aefe8b85d9f9b9d18ae496be42e4f73378dab00da0d0bfa853ae03449bad895a6c5ac0c36cae80f1bfdef77fa7ad8f79fd99123f8d201d83ce0f0a9675a47c2
|
7
|
+
data.tar.gz: 77774c2a3e201ed5f4a09fc72432478dc4e4866f9e9c17cd186877e91e1c74a2ef76fd5578b837e85857bfc36f32ca9cb41ab944fde422cb82350d1235e3e953
|
data/lib/blender-3d/model.rb
CHANGED
@@ -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
|
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
|
data/lib/blender-3d/pointer.rb
CHANGED
@@ -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
|
data/lib/blender-3d/version.rb
CHANGED