@@ -70,6 +70,7 @@ class DimensionDecorator(ViewDecorator):
7070 // converting to and from square-space coordinates to calculate arrows
7171 mat4 clip2square = mat4(aspect, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
7272 mat4 square2clip = mat4(1/aspect, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
73+
7374 vec4 dir = normalize((p1 - p0) * clip2square) * length;
7475 vec4 head = dir * square2clip;
7576 vec4 arr_a = dir * rot_a * square2clip;
@@ -212,12 +213,20 @@ def coords(segm):
212213 batch = batch_for_shader (self .shader , 'LINES' , {'pos' : points })
213214 self .shader .bind ()
214215
215- matrix = self .context .region_data .perspective_matrix
216+ region = self .context .region_data
217+ matrix = region .perspective_matrix
216218 aspect = self .context .region .width / self .context .region .height
217219 self .shader .uniform_float ("viewMatrix" , matrix )
218220 # TODO: get everything from styles
219221 self .shader .uniform_float ('aspect' , aspect )
220222 self .shader .uniform_float ('color' , (1.0 , 1.0 , 1.0 ))
221223 self .shader .uniform_float ('angle' , math .pi / 12 )
222- self .shader .uniform_float ('length' , 32 / self .context .region .height )
224+
225+ # brute-force perspective fix
226+ # TODO: move the fix into shader + align heads to view plane
227+ length = 32 / self .context .region .height
228+ if region .is_perspective :
229+ length *= 8
230+
231+ self .shader .uniform_float ('length' , length )
223232 batch .draw (self .shader )
0 commit comments