API convert closestPoint in worldSpace


#1

Hi community,

  I am trying to convert a closestPoint from MMeshIntersector to worldSpace but it doesn't seem to work and I can't figure out why. 
  
  I have a direct connection to my deformer to get the wordMatrix of my influence. for test purpose everything is at the origin.  My worldSpace matrix is [[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1]] (i can see it in my matricesArray attribute) which seems correct. but when I print my matrix, it prints : [[5.26354e-315, 0, 0.0078125, 0], [0, 5.26354e-315, 0, 0.0078125], [4.24399e-314, 5.26354e-315, 0, 0.0078125], [0, 0, 5.26354e-315, 0]]
  
  I assume this is wrong ...
  here is how I access my matrix data : 

      MArrayDataHandle h_influencesMatrix = data.inputArrayValue(a_infWorldMatrices, &status);
      h_influencesMatrix.jumpToElement(infIndex);
      MMatrix m_influenceWorldSpace = h_influencesMatrix.inputValue().asMatrix();
 Can't figure out why I have this difference ...
 Thx

#2

Could it be that you made the attribute as MFloatMatrix and you are retrieving it as a MMatrix? This might give you the wrong values.


#3

Good point, I will double check that (tonight), will let you know. One of my colleagues also told me that I should probably connect the transform.worldMatrix instead of the shape.


#4

That shouldn’t actually matter that much. On the shape should be totally fine.

Somewhat unrelated: Note that the reason worldMatrix is an array is because it has a matrix per instance. You aren’t using instances in your test case right? Might be that you’re using the wrong index then.


#5

Yeah in my test I have multiple influences with the associated matrix and all the influences are at the origin, so it shouldn’t matter if I have the wrong index as all matrices are the same (in this specific case.)


#6

So the problem was that I defined the matrix attribute as Float and it should be double if I want to use MMatrix later.