Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
physics [2020/05/24 13:25] – [Callbacks] adminphysics [2020/05/24 13:27] – [Callbacks] admin
Line 210: Line 210:
 procedure TUIMainWin.doOnBeginContact(const ABodyA, ABodyB : TQ3Body); procedure TUIMainWin.doOnBeginContact(const ABodyA, ABodyB : TQ3Body);
 begin begin
 +    if not Assigned(ABodyA.UserDataType) then
 +      Exit;
 +    if not Assigned(ABodyB.UserDataType) then
 +      Exit;      
 +      
     if TComponent(ABodyA.UserData).Name.Equals('Cube1') and TComponent(ABodyB.UserData).Name.Equals('Sphere2') then     if TComponent(ABodyA.UserData).Name.Equals('Cube1') and TComponent(ABodyB.UserData).Name.Equals('Sphere2') then
     begin     begin
       FMX.Types.Log.D('expected collision between %s <=> %s',        FMX.Types.Log.D('expected collision between %s <=> %s', 
         [TComponent(ABodyA.UserData).Name, TComponent(ABodyB.UserData).Name]);         [TComponent(ABodyA.UserData).Name, TComponent(ABodyB.UserData).Name]);
 +    end
 +    else
 +    begin
 +      FMX.Types.Log.D('<ERROR> unexpected collision between %s <=> %s', 
 +        [ABodyA.UserDataType^.Name, ABodyB.UserDataType^.Name]);
     end;     end;
  end;  end;