Opened 10 years ago

Last modified 9 years ago

#2913 closed task

[PATCH] Better way to handle visibilities in the simulation — at Version 14

Reported by: Itms Owned by: Itms
Priority: Should Have Milestone: Alpha 18
Component: Core engine Keywords:
Cc: Patch:

Description (last modified by Itms)

My work on #599 allowed me to work on the visibility systems (fog-of-war, line of sight, etc.), and currently, a large part of the visibility logic is handled by the RangeManager system component, especially in this function.

As a consequence, scripted components can't influence the visibility of an entity. Mods, but also planned features for the main game (like Iberian camouflaged units), would need a way to influence this visibility. Also, the way I plan to tackle #2710 needs it.

I propose to separate this logic into a Visibility component. Several things could benefit from this change.

I think it would be better to do changes in separate patches/commits, to avoid complexity and possible regressions. So I set this ticket as a task, and I will use it to track the changes. Remaining planned changes:

  • Create the Visibility component
  • Find a way to remove the hardcoded and duplicated VIS_FOO in the scripted components Fogging, Mirage and Visibility
  • Move template items GetRetainInFog and AlwaysVisible from Vision to Visibility
  • Update component documentations (RangeManager, Visibility), including code comments
  • Fix #2710 with the new system
  • Improve #958 with the new system if possible (see this TODO)
  • For fun, implement camouflaging for some units

Change History (16)

comment:1 by Itms, 10 years ago

In 15925:

Add a new Visibility component that will eventually allow scripted components and mods to influence an entity's visibility.

This first commit only refactors code and does not add any new feature.

Refs #2913 (see this ticket for more information about the change)

comment:2 by Itms, 10 years ago

Description: modified (diff)

comment:3 by Itms, 10 years ago

In 15939:

Fix actors not retained in FoW after r15925.
Refs #2913.

comment:4 by Itms, 9 years ago

In 16022:

Move template items GetRetainInFog and AlwaysVisible from Vision to Visibility.

Refs #2913

comment:5 by Itms, 9 years ago

Keywords: review patch added

Here is a patch to use the cached visibility (introduced for mirages) for any entity. This would reduce the number of computations of the visibility, which is currently huge, but no profiling was done yet. I will come up with some data but I post the patch for review in the meantime.

by Itms, 9 years ago

Attachment: use_cached_visibility.patch added

comment:6 by Itms, 9 years ago

Keywords: review patch removed

Committed above patch in r16166.

comment:7 by Itms, 9 years ago

Here is a patch moving back the computation of visibilities to C++. Now, the scripted component is called only if necessary.

As a use case of the scripted part, I fixed the TODO remaining from #958.

However, a style improvement would be handling properly the empty properties of scripted components in templates. For instance, currently Decay has an <Inactive/> component, well handled in C++, but I was forced to write <Preview>true</Preview> in my case to make the code work. This must be fixed before committing.

comment:8 by Itms, 9 years ago

Keywords: review patch added
Summary: Better way to handle visibilities in the simulation[PATCH] Better way to handle visibilities in the simulation

comment:9 by Itms, 9 years ago

Updated the template thing after getting Philip's input on IRC.

comment:10 by Itms, 9 years ago

In 16175:

Clean up redundancies in templates for the Visibility component, refs #2913

comment:11 by Itms, 9 years ago

Fixed the patch, which didn't actually work.

comment:12 by Itms, 9 years ago

Cc: historic_bruno added

Hi Ben, could you take a look at the latest patch, which works around a code you wrote? I'd like to commit it asap, probably tomorrow. Thanks in advance :)

comment:13 by Itms, 9 years ago

In 16248:

Move back the computation of most of the visibilities from JS to engine, to improve performance.

Also fix the remaining TODO left by #958, as a use case of the scripted Visibility component.

Refs #2913, #958.

comment:14 by Itms, 9 years ago

Description: modified (diff)

Attached patch reduces drastically the number of mirages by making fogging conditional: entities will be miraged only if their health/resource amount is reduced, or if they have a non-gaia owner.

It also cleans out the code in some parts, and fixes the invisible animals problem and the missing status bars for mirages.

I'll commit it on Friday evening, so please give feedback :)

Note: See TracTickets for help on using tickets.