Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: maxViewDistance, maxViewDistanceAtDark moved into ruleset #904

Closed
wants to merge 16 commits into from

Conversation

@redv
Copy link
Contributor

redv commented Jul 17, 2014

Update of #698
A bit rewritten.

@Volutar

This comment has been minimized.

Copy link
Contributor

Volutar commented Jul 18, 2014

Please make clearer PRs, with not cluttered history.

@@ -8704,6 +8704,9 @@ startingTime:
day: 1
month: 1
year: 1999
maxViewDistance: 20
maxViewDistanceAtDark: 9
maxDarknessToSeeUnits: 9

This comment has been minimized.

Copy link
@redv

redv Jul 19, 2014

Author Contributor

Constants maxViewDistance, maxViewDistanceAtDark and maxDarknessToSeeUnits moved into ruleset instead hardcode.

distance(currentUnit->getPosition(), tile->getPosition()) > 9 &&
tile->getShade() > MAX_DARKNESS_TO_SEE_UNITS)
distanceSq(currentUnit->getPosition(), tile->getPosition(), false) > getMaxViewDistanceAtDarkSqr() &&
tile->getShade() > getMaxDarknessToSeeUnits())

This comment has been minimized.

Copy link
@redv

redv Jul 19, 2014

Author Contributor

Member distance() uses sqrt() from standard library. Changed to distanceSq() because of performance http://assemblyrequired.crashworks.org/2009/10/16/timing-square-root/

{
if (t != _save->getTile(Position(_trajectory.at(i).x/16,_trajectory.at(i).y/16, _trajectory.at(i).z/24)))
_trajectory.at(i) /= voxelToTile;
if (posTile != _trajectory.at(i))
{

This comment has been minimized.

Copy link
@redv

redv Jul 19, 2014

Author Contributor

Instead of calculating getTile() each voxel, calculates only coordinates. getTiles() calls only if really reached next tile. Therefore we got a bit performance.

// 20 - maximum view distance in vanilla Xcom.
// Even if MaxViewDistance will be increased via ruleset, smoke will keep effect.
if (visibleDistance > getMaxVoxelViewDistance() - densityOfSmoke * getMaxViewDistance()/(3 * 20))
{

This comment has been minimized.

Copy link
@redv

redv Jul 19, 2014

Author Contributor

Calculation of visibleDistance takes into account possibility of changing MaxVoxelViewDistance via ruleset.
Instead of checking visibleDistance each voxel, checked only one time per tile. Therefore performance will be increased especially for long range.

This comment has been minimized.

Copy link
@redv

redv Jul 20, 2014

Author Contributor

To make it clear, if cloud of smoke reduces visibility in 4 times (i.e. from 20 to 5 tiles), then after increasing maxViewDistance (i.e. 100 tiles) this cloud of smoke also will reduce visibility in 4 times (from 100 to 25 tiles).

int z = pos1.z - pos2.z;
sq += z*z;
}
return sq;

This comment has been minimized.

Copy link
@redv

redv Jul 19, 2014

Author Contributor

Optimization of distanceSq() in case of 2D calculation. Performance of 3D calculation will be the same.

@redv redv force-pushed the redv:view_distance branch from d0afe42 to 51e1b09 Aug 24, 2014
@redv redv force-pushed the redv:view_distance branch 2 times, most recently from 84e62ef to 4b9b92f Sep 14, 2014
@redv redv force-pushed the redv:view_distance branch from 4b9b92f to 12a3916 Sep 14, 2014
redv added 6 commits Sep 27, 2014
	src/Ruleset/Armor.cpp
	src/Ruleset/Ruleset.cpp
	src/Ruleset/Armor.cpp
	src/Ruleset/Armor.h
	src/Savegame/SavedBattleGame.cpp
	bin/data/Ruleset/Xcom1Ruleset.rul
	src/Battlescape/BattlescapeGenerator.cpp
	src/Battlescape/TileEngine.cpp
	src/Battlescape/TileEngine.h
	src/Ruleset/Ruleset.cpp
	src/Ruleset/Armor.cpp
	src/Ruleset/Armor.h
	bin/data/Ruleset/Xcom1Ruleset/vars.rul
	src/Ruleset/Ruleset.cpp
	src/Ruleset/Ruleset.h
@SupSuper

This comment has been minimized.

Copy link
Member

SupSuper commented May 7, 2018

Superceded by OXCE

@SupSuper SupSuper closed this May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.