Check the coherence of the model

Returns false on error and prints details to stderr.

This service can be useful for debugging, however it should not be executed at each execution of a game.

Property definitions

gamnit $ ObjDef :: is_coherent
	# Check the coherence of the model
	#
	# Returns `false` on error and prints details to stderr.
	#
	# This service can be useful for debugging, however it should not
	# be executed at each execution of a game.
	fun is_coherent: Bool
	do
		for obj in objects do
			for f in obj.faces do
				if f.vertices.length < 3 then return error("Face with less than 3 vertices")
			end

			for f in obj.faces do for v in f.vertices do
				var i = v.vertex_point_index
				if i < 1 then return error("Vertex point index < 1")
				if i > vertex_points.length then return error("Vertex point index > than length")

				var j = v.texture_coord_index
				if j != null then
					if j < 1 then return error("Texture coord index < 1")
					if j > texture_coords.length then return error("Texture coord index > than length")
				end

				j = v.normal_index
				if j != null then
					if j < 1 then return error("Normal index < 1")
					if j > normals.length then return error("Normal index > than length")
				end
			end
		end
		return true
	end
lib/gamnit/model_parsers/obj.nit:178,2--210,4