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

479 onboarding of new see members yvo #485

Closed
wants to merge 7 commits into from

Conversation

Yvo02
Copy link
Collaborator

@Yvo02 Yvo02 commented Oct 26, 2022

marking a node with a red sphere above

Added functionality for GameNodeMarker, MarkAction and MarkNetAction. Extended ActionStateType with a new spacebar action for marking an element.
@Yvo02 Yvo02 linked an issue Oct 26, 2022 that may be closed by this pull request
4 tasks
Copy link
Collaborator

@falko17 falko17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left a few suggestions for this PR below.

Assets/SEE/Game/GameNodeMarker.cs Outdated Show resolved Hide resolved
Assets/SEE/Game/GameNodeMarker.cs Outdated Show resolved Hide resolved
Assets/SEE/Game/GameNodeMarker.cs Outdated Show resolved Hide resolved
Assets/SEE/Game/GameNodeMarker.cs Outdated Show resolved Hide resolved
Assets/SEE/Game/GameNodeMarker.cs Outdated Show resolved Hide resolved
Assets/SEE/Game/GameNodeMarker.cs Outdated Show resolved Hide resolved
Assets/SEE/Game/GameNodeMarker.cs Outdated Show resolved Hide resolved
Yvo02 and others added 3 commits October 26, 2022 14:19
Changed documentation as suggested

Co-authored-by: Falko <10247603+falko17@users.noreply.github.com>
Co-authored-by: Falko <10247603+falko17@users.noreply.github.com>
Copy link
Collaborator

@koschke koschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made few suggestions for improvement. They don't need to be implemented because that was intended only as an exercise.

/// <summary>
/// The position of the new marker in world space.
/// </summary>
public readonly Vector3 Position;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GameNodeMarker could take care of position and scale of the sphere. No need to bother with these here.

/// The game object that was added when this action was executed. It is saved so
/// that it can be removed by Undo().
/// </summary>
private GameObject addedSphere;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unmarking, i.e., destruction of the added sphere, could be handled by GameNodeMarker.

{
GameObject sphere;

if(parent == null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a blank between if and (.

base.Undo();
if (addedSphere != null)
{
new DeleteNetAction(addedSphere.name).Execute();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addedSphere.name would need to be unique. In your implementation I cannot see how this is guaranteed.

Moreover, DeleteNetAction is generally intended to be used to delete nodes or edges. We would need to check whether it is safe to be used for other kinds of game objects, too.

return new HashSet<string>
{
memento.Parent.name,
memento.NodeID
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conflict resolution via GetChangedObjects() is intended for nodes and edges, not for decorations of these. Since marks can be toggled only via their containing node, the conflict resolution for its containing node should suffice. Moreover, memento.NodeID would need to be unique.

/// <param name="worldSpaceScale">the scale in world space of the new marker</param>
/// <returns>new marker game object or null if none could be created or a marker already exists</returns>
/// <exception cref="ArgumentNullException">If <paramref name="parent"/> is <c>null</c>.</exception>
public static GameObject AddSphere(GameObject parent, Vector3 position, Vector3 worldSpaceScale)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As stated above, AddSphere could determine the necessary position and scale of the sphere. No need to pass these as parameters.

sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
float diameter = Math.Min(worldSpaceScale.x, worldSpaceScale.y);
sphere.transform.localScale = new Vector3(diameter, diameter, diameter);
sphere.transform.position = new Vector3(position.x, position.y + 0.1f, position.z);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to use a named constant instead of the magic number 0.1f.

if (child.name == "Sphere")
{
//FIXME: network operation for deleting an existing marker not working properly
//new DeleteNetAction(sphere.name).Execute();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeleteNetAction should never be called here. That needs to be handled by the client of GameNodeMarker. This helper class GameNodeMarker whole purpose is to make changes to the scene.

@koschke koschke closed this Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Onboarding of new SEE members
3 participants