@@ -163,8 +163,7 @@ def test_bad_manifold(self):
163163class TestVector (utils .TestCase ):
164164 def test_bad (self ):
165165 self .assertIsNone (Model .vector (None , None ))
166- self .assertIsNone (Model .vector ('hello' , 1 ))
167- self .assertIsNone (Model .vector (1 , 'hello' ))
166+ self .assertIsNone (Model .vector (None , 1 ))
168167
169168 def test_basic (self ):
170169 vertices = [0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 1 , 0 , 1 , 0 , 1 , 1 ]
@@ -179,6 +178,15 @@ def test_basic(self):
179178 self .assertAlmostEqual (mesh .area , 3 + math .sqrt (2 ))
180179 self .assertAlmostEqual (mesh .volume , 0.5 )
181180
181+ def test_convex (self ):
182+ vertices = [- 1 , - 1 , - 1 , 1 , - 1 , - 1 , - 1 , 1 , - 1 , 1 , 1 , - 1 , - 1 , - 1 , 1 , 1 , - 1 , 1 , - 1 , 1 , 1 , 1 , 1 , 1 ]
183+ model = Model .vector (vertices )
184+ self .assertIs (model , Model .vector (vertices ))
185+ mesh = model .get_trimesh ()
186+ self .assertEqual (mesh .bounds .tolist (), [[- 1 , - 1 , - 1 ], [1 , 1 , 1 ]])
187+ self .assertAlmostEqual (mesh .area , 24 )
188+ self .assertAlmostEqual (mesh .volume , 8 )
189+
182190 def test_invalid (self ):
183191 with unittest .mock .patch ('flitter.render.window.models.logger' ) as mock_logger :
184192 model = Model .vector ([0 , 0 , 0 , 0 , 0 , 1 , 0 , 1 ], [0 , 1 , 2 ])
0 commit comments