Guest User

Untitled

a guest
Nov 24th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.96 KB | None | 0 0
  1. diff -r 5883d1d37ab8 src/luxrender/export/__init__.py
  2. --- a/src/luxrender/export/__init__.py  Thu Sep 08 21:15:26 2011 -0700
  3. +++ b/src/luxrender/export/__init__.py  Tue Sep 13 22:53:04 2011 +0200
  4. @@ -262,35 +262,27 @@
  5.         return ws
  6.  
  7.  def object_anim_matrix(scene, obj, frame_offset=1, ignore_scale=False):
  8. -   if obj.animation_data != None and obj.animation_data.action != None and len(obj.animation_data.action.fcurves)>0:
  9. -       next_frame = scene.frame_current + frame_offset
  10. -      
  11. -       anim_location = obj.location.copy()
  12. -       anim_rotation = obj.rotation_euler.copy()
  13. -       anim_scale    = obj.scale.copy()
  14. -      
  15. -       for fc in obj.animation_data.action.fcurves:
  16. -           if fc.data_path == 'location':
  17. -               anim_location[fc.array_index] = fc.evaluate(next_frame)
  18. -           if fc.data_path == 'rotation_euler':
  19. -               anim_rotation[fc.array_index] = fc.evaluate(next_frame)
  20. -           if fc.data_path == 'scale':
  21. -               anim_scale[fc.array_index] = fc.evaluate(next_frame)
  22. -      
  23. -       next_matrix  = mathutils.Matrix.Translation( mathutils.Vector(anim_location) )
  24. -       anim_rotn_e = mathutils.Euler(anim_rotation)
  25. -       anim_rotn_e.make_compatible(obj.rotation_euler)
  26. -       anim_rotn_e = anim_rotn_e.to_matrix().to_4x4()
  27. -       next_matrix *= anim_rotn_e
  28. -      
  29. -       if not ignore_scale:
  30. -           next_matrix *= mathutils.Matrix.Scale(anim_scale[0], 4, mathutils.Vector([1,0,0]))
  31. -           next_matrix *= mathutils.Matrix.Scale(anim_scale[1], 4, mathutils.Vector([0,1,0]))
  32. -           next_matrix *= mathutils.Matrix.Scale(anim_scale[2], 4, mathutils.Vector([0,0,1]))
  33. -      
  34. -       return next_matrix
  35. +   # save current object matrix
  36. +   matrix_orginal = obj.matrix_world.copy()
  37. +  
  38. +   # save current scene frame
  39. +   current_frame = scene.frame_current
  40. +   next_frame = current_frame+frame_offset
  41. +  
  42. +   # move forward with frame_offset
  43. +   scene.frame_set(next_frame)
  44. +  
  45. +   # get new matrix of object
  46. +   matrix_new = obj.matrix_world.copy()
  47. +  
  48. +   # move frame backward
  49. +   scene.frame_set(current_frame)
  50. +  
  51. +   # compare the matrices if equal, then return false
  52. +   if matrix_compare(matrix_orginal, matrix_new) == True: 
  53. +       return False
  54.     else:
  55. -       return False
  56. +       return matrix_new
  57.  
  58.  def matrix_to_list(matrix, apply_worldscale=False):
  59.     '''
  60. @@ -331,3 +323,31 @@
  61.         paramset.add_string('%s_data' % parameter_name, encoded_data.splitlines() )
  62.     else:
  63.         paramset.add_string(parameter_name, file_relative)
  64. +      
  65. +def compare_floats(f1, f2):
  66. +   '''
  67. +       compare two floats
  68. +   '''
  69. +   epsilon = 1e-6
  70. +   if(math.fabs(f1 - f2) > epsilon):
  71. +       return False
  72. +   else:
  73. +       return True
  74. +
  75. +def matrix_compare(matrixA, matrixB):
  76. +   '''
  77. +       compare two matrices and returns True or False
  78. +   '''
  79. +  
  80. +   if (matrixA.col_size != matrixB.col_size) or (matrixA.row_size != matrixB.row_size):
  81. +       return False
  82. +  
  83. +   rows = matrixA.row_size
  84. +   cols = matrixA.col_size
  85. +   # iterate over the matrix
  86. +   for row in range(rows):
  87. +       for col in range(cols):
  88. +           if compare_floats(matrixA[row][col], matrixB[row][col]) == False:
  89. +               return False
  90. +  
  91. +   return True
  92. \ No newline at end of file
Add Comment
Please, Sign In to add comment