QC 125635

QC 125635

Found a bug in XE4, can someone see if this is still in XE6?

When you use several lights in your FMX 3D application (3 or more)
you probably want to enable and disable lights at runtime.

Doing this you run into the problem: some of the enabled lights will be ignored, depending on the order you added the lights to the application.

The bug is in the FMX.Materials unit. I fixed it there, no workaround.

Comments

  1. It would appear to have been fixed: in XE6, the procedure TLightMaterial.DoApply starts with the following lines:

      // lights
      CLight := 0;
      for i := 0 to Context.Lights.Count - 1 do
        if Context.Lights[i].Enabled then
          Inc(CLight);
      CLight := Min(TContext3D.MaxLightCount, CLight);

    ReplyDelete
  2. the start is similar in XE4,
    but the bug is further down in the method, this line:
    for i := 0 to Min(MaxLightCount, Context.Lights.Count) - 1 do

    ReplyDelete
  3. Ah. I see what you mean. Then no, it hasn't been fixed. That code is still as follows:
      // lights
      if MaxLightCount > 0 then
      begin
        CLight := 0;
        for i := 0 to Min(MaxLightCount, Context.Lights.Count) - 1 do
          if Context.Lights[i].Enabled then
          begin
            LLight := Context.Lights[i];

    ReplyDelete
  4. BTW, perhaps you should add a line with
      // ...
    to your code snippet to indicate that you've omitted lines of code. Or specify the line number where the error occurs; that would make it easier to spot which line you're talking about.

    ReplyDelete
  5. Good point, but it is in the project attached to the QC entry. ;)

    ReplyDelete
  6. Thanks to Tomohiro Takahashi,
    who took the time to test it out in XE6,
    the report is now open.
    (same day)

    ReplyDelete

Post a Comment