TODO List - GabrieleGiuseppini/Ship-Sandbox GitHub Wiki

= Mask with copyright at all source files (copy from XXmain)
	+ Already capitalized
	- Those to be capitalized
		+ material
			+ Rename
			+ cctors:
				+ from picojson obj
			+ Create()->UQ_PTR
				+ private cctor
				+ all members const
			+ optional Material::ElectricalProperties
		+ Also Renderer becomes a namespace, not a class
		+ render
			+ Renderer
			+ move ScreenToWorld here
			+ All static methods, inline
		+ util
		- phys: Physics.h
			- Rename as Ship, World, Point, etc.
			- TODO: see if can split into separate files
				- commit & push first
			- no more warnings
		+ vec

- Phys rearc:
	+ Confirmed: destroy breaks due to iterator invalidation
	+ In order to allow for ship building unit tests:
		+ static unique_ptr Ship::Create(unsigned char const * structureImageData, un_map)
		+ void World::AddShip(unique_ptr && newShip)
		+ Game::LoadShip(filename) still loads the image, and then Ship::Create and World::AddShip
	+ Ship_BuildsFromStructureImage_XXX unit test:
		+ Make structureImageData and verify points, springs, triangles, etc., also indexes & relationships
			+ Might actually want Material::cctor to be public
	+ Destroy unit tests:
		+ Make structureImageData
		+ DestroyAt
		+ Verify points, springs, triangles, etc., also indexes & relationships
		+ Verify crashes in Debug!
	- Do phys renames and file split above
	- Repository rearc:
		= PointerContainer
			- Expose inner vector?
			- ShrinkToFit: no memcpy but ptr copy iff p2 != p1	
				- Two loops	
		- Take perf baseline
		- Ship maintains lifetime of points, springs, and triangles in backbones 
			- Springs: PointerContainer
			- Test perf
			- Others: depends, if fast iterator access in arbitrary order is needed => PointerContainer
		- Others indexes are XByY (e.g. mSpringsBySpring, i.e. by ptr)
		- Point has all its counterparties, including adjacent points
		- Others have all their counterparties
		- x::Destroy()  // all own references in counterparties
				// sets self.IsDeleted = true
				// Invokes Destroy() on counterparties it owns (e.g. Point->Spring)
		- After each deletion, Ship calls shrink_to_fit on owner pointer container

		OLD
		- Ship maintains lifetime of points, springs, and triangles in backbones
			- un_map, for all but allSprings, and vector<> for allSprings
			- alternatively: un_map for all, and DoSprings builds vector w/iterators (to avoid advance)
		- Point has all its counterparties, including adjacent points
		- Others have all their counterparties
		- x::Dislodge() // self and all own references in counterparties
				// Invokes DislodgeAndRemove on counterparties it owns (e.g. Spring->Point)
		- X::DislodgeAndRemove() // Dislodge() and ask ship to remove from backbone (requires parentShip* for each!)
			- Or done by caller @ caller's Dislodge() after called counterparty::Dislodge()
				- Not all need parentShip* then
				- Also, consider root Dislodge() taking ship* to save on parentShip* members

	- Complete unit tests with all new relationships

= Perf optimizations:
	+ Move back to baseline
	+ Take profile X 2
	+ set these flags and see impact (on Release)
		+ Ox
		+ fp:fast
	+ Flags for non-MSVC:
				
					
					
					
					
					
					
				
	+ Make all render() const
	+ Make all render() inline
	- phys getters (e.g. point.getColour()) inline
	- Cleaning pass in phys
	+ Make all vector funcs inline in .h
	- Optimization for NThreads=1
		- Need new benchmark afterwards

- Compare old (released) look with this one, and see if there are changes (in phys, render,...) to take in
	- Also jellyfish fixed in 1.2.6?

- FileDialog: filters based off image formats that are supported
- Move IsPaused out of game controller & parameters; handled by MainFrame via status of mPauseMenuItem
- See if destroy's lack of point allows for water to flow in
	
+ Data/
	+ InitialShip.png [also change @ code]
	+ Materials

- Zoom: inverse?
	- 0 - 1000
		- Renderer::ZoomToWorldY(zoom) == 70/(zoom + 0.001)
		+ Also called by GameController's Screen2World 
			+ also move GameController's Screen2World implementation to Renderer

+ Frustum? For 2D? Try Ortho?

+ Change MainFrame's build info
	+ separate Version.h

- Clean all warnings

- is Verlet implemented right?


- no memory leaks at all (no heap alloc's outside of unique_ptr)
- See if can continue queueing tasks without waiting for all blocks of chunks

- Game interactions:
	- IGameEventSink: individual methods, including parameter changes, all default-implemented
		- OnDestroy(Material const *, size)
		- OnBreak(Material const *, size) // size=1 for each break, but Dispatcher aggregates
	- GameController::RegisterGameEventSink(IGameEventSink *)
		- calls into GameEventDispatcher::RegisterGameEventSink, who does:
			- Registration of sinks
			- Aggregation of duplicate events (is called at step start/step end)
				- e.g.: OnBreak: keep distinct Material * and count for size
	- GameController gives shared_ptr to Game at Game's cctor
	- Sound:
		- MainApp initializes SoundController, which implements IGameEventSink
			- Initializes off visit of Data/Sounds, w/Music and Sounds
				- Mapping of sounds with IGameEventSink events via:
					- Material::optional<_SoundProperties>
						- SoundMaterial: enum(wood, metal, ...)
					- Filename patterns of sounds and music (e.g. destroy_wood_1.wav)
						- Parse: if 'destroy'=>expect SoundMaterial next, then ...
							- Material enums have StrToX()
					- Sounds stored in maps (of maps of...) indexed by coordinates off filename patterns
						- Material's enums used as coordinates
			- wxSound or SFML (with https://www.sfml-dev.org/tutorials/2.4/audio-sounds.php)
			- Need to manage lifetime of Sound objects 
				- Use queue and, when full, visit and pop (deleting Sound) those sounds that are done
					- If still full, stop last and pop it
		- MainApp registers SoundController as sink with GameController
		- MainApp passes SoundController as shared_ptr to MainFrame (exactly like GameController)
			- So MainFrame can configure it via options

- Lights
	+ need Optional()
	+ Material:
		+ use picojson
		+ Material.ElectricalProperties (optional)
			+ type (Material::ElectricalProperties::ElectricalElementType=lamp, cable, generator)
			+ flat list of all electrical properties, some apply some don't
	- class Lamp()
		- points to Point and Point points optionally to ElectricalElement (base abstract of Lamp, Cable, Generator)
	- Algo:
		- create new generation seq number; if new is 0 => 1
		- visit all generator points and count the points in their graphs; for each connected component:
			- # nodes in component => current
			- propagate from each of these points to all adjacent cables until light
			- at the light: add up all incoming currents (lowered by distance) and update gen number
		- visit all lights:
			- if gen number != current: just interrupted
				- set gen_number = 0
				- start flicker state machine
			- else: nop (will be rendered as lighted, depending on current)


- Save photos (opens SaveAs FileDialog)
	
- Magnifying glass
	- https://www.opengl.org/discussion_boards/showthread.php/154811-magnifying-glass-effect
	- https://www.shadertoy.com/view/4tdXDl

- Water with OpenGL particle effects
- ocean depth bitmaps

+ see if it makes sense that ship::points is set>
+ nuke wxSmith
	+ Verify all is fine afterwards

+ set icon

==============================================================================
==============================================================================
==============================================================================
==============================================================================
==============================================================================
==== DONE
==============================================================================
==============================================================================
==============================================================================
==============================================================================
==============================================================================

+ Build glfw yourself
	+ clone from git
	+ build
	+ fix Ship's CMake
		+ C:\Users\Neurodancer\source\build\glfw\src\Release
+ move to source/build:
	+ ShipSandbox

IF WX:
+ build WX (Debug, Release)
+ add WX to CMakeFiles.txt
	C:\Users\Neurodancer\source\repos\wxWidgets\include
	C:\Users\Neurodancer\source\repos\wxWidgets\lib\vc_x64_lib
		names: wxmsw31u[d]_core.lib wxbase31u[d].lib
+ remove titanicapp.*, titanicmain.* from CMakeFiles.txt
+ do a simple main with wx
+ rebuild WX with C++ Runtime being statically linked
+ test
+ see getting rid of whole wx.h and only include wxwindow
+ get rid of GLFW in all source files
+ setup CMakeFiles.txt: Remove GLFW
+ resuscitate old code, merging it with new existing structure:
	+ mainApp - mainApp class, main #define
	+ mainFrame - entire frame
+ test	
+ remove titanicapp.*, titanicmain.*, main_old.cpp
+ one-shot timer
+ nuke GLFW from hard disk (repo, build)
+ add logger and fix missing ship

+ Get perf baseline and start Readme.md and Changes.txt

===========
+ cherry-pick that typo fix
+ logging window: try http://docs.wxwidgets.org/3.0/classwx_text_ctrl.html
+ rename members of Frame, cleanup code

+ Render/Game"Settings" -> "Parameters"
+ LoggingWindow -> "Dialog"

+ SettingsDialog:
	+ Add spacing
	+ Taller sliders
	+ Min and Max
	+ add textboxes 4 vals
	+ ApplySettings()
		+ GameController takes (& gives) absolute vals, & provides GetXMax/MinValue() (from YYYParameters)
		+ Helper funcs in SettingsDialog do conversions
	+ ReadSettings()
	+ Other controls for other settings
	+ rename members, cleanup code

+ MainFrame:
	+ LogWindow bug when minimizing and maximizing main frame
	+ Do we need mMainGLCanvas and context to be unique_ptr's?
	+ Render once @ beginning
		+ Check if OnPaint is the right one
	+ Maximize
	+ ReloadLastSelected
	+ See if canvas.setcontext is necessary
		+ Watch out for resize
	+ +/- for zoom *IN MENU*
		+ remove wxEVT_CHAR_HOOK at panel and use menu hotkey and event instead

+ Investigate dirty lines

+ Use own exception

+ Fix DestroyAt
	+ Add DestroyRadius to GameParameters (not in SettingsDialog yet)

+ Fix final destroyer

+ Setup UnitTests
	+ Build GTest Debug and Release
	+ Create UnitTests project in CMake
	+ First unit test: vectors

+ GameException: cctor with string
	+ Utils::Convert(string)->wstring

+ Rebuild Devil but make it a dll with static runtime
+ Move DevIL init to GameController
	+ No DevIL dep's in ShipSandbox
	+ DevIL_INCLUDEs from GameLib are not public

+ Move to picojson
	+ Nuke SDK
	+ Remove public-ness of JSonCPP

+ Settings: 
	+ Destroy Radius
	+ "World"XYZ if really it is world
⚠️ **GitHub.com Fallback** ⚠️