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

GenericCAO models are dark when below y = 0 #6174

Closed
paramat opened this issue Jul 26, 2017 · 13 comments
Closed

GenericCAO models are dark when below y = 0 #6174

paramat opened this issue Jul 26, 2017 · 13 comments
Assignees
Labels
Bug Issues that were confirmed to be a bug @ Client / Audiovisuals

Comments

@paramat
Copy link
Contributor

paramat commented Jul 26, 2017

Testing on a local server:

screenshot_20170726_015326

screenshot_20170726_015341

Jumping or hovering slightly above a node makes light return, so i suspect that the recent 'player settable collisionbox' change has shifted the point that defines player model light down by a node to feet position, and that being below y = 0 is a sign reversal that puts that point just inside the node below.
If so then when above y = 0, flying very slightly into the ground should make the player go dark too:

screenshot_20170726_015602

screenshot_20170726_015620

Confirmed. So it seems that a 1-node vertical offset was forgotten somewhere.
@TeTpaAka

@paramat
Copy link
Contributor Author

paramat commented Jul 26, 2017

I might know why. Previously player pos was centre of model, now it's foot position, so light is being sampled at foot position, we need to add in a vertical offset to raise this point back up to model centre, or, up by 1 node. If we raise by 0.9 * BS this will be rough model centre. But only for player objects.

@paramat
Copy link
Contributor Author

paramat commented Jul 26, 2017

https://github.com/minetest/minetest/blob/master/src/content_cao.cpp#L944

v3s16 GenericCAO::getLightPosition()
{
	return floatToInt(m_position, BS);
}

Compare to items:

v3s16 ItemCAO::getLightPosition()
{
	return floatToInt(m_position + v3f(0,0.5*BS,0), BS);
}

But i'm concerned about any added offset being applied to all CAOs instead of just players.

@kaadmy
Copy link

kaadmy commented Jul 26, 2017

Just so you know, ItemCAO doesn't seem used outside of content_cao.cpp.

@kaadmy
Copy link

kaadmy commented Jul 26, 2017

Doesn't the player have a seperate subclass of GenericCAO?

@nerzhul
Copy link
Member

nerzhul commented Jul 26, 2017

if i remember ItemCAO is obsolete

@paramat
Copy link
Contributor Author

paramat commented Jul 26, 2017

Ok.
Fot genericCAO i think it's best to go with
return floatToInt(m_position + v3f(0, 0.5 * BS, 0), BS);
to work with mobs / players that are 1 node high, this is also halfway up a node height so is a good general light position, i'll make a PR.

@Wuzzy2
Copy link
Contributor

Wuzzy2 commented Jul 27, 2017

This is not just for player models, but for any models. I have seen this for item entities, boats, carts, mobs and pretty much any entity based on a mesh.

@paramat
Copy link
Contributor Author

paramat commented Jul 27, 2017

Yes but that's different and a non-issue, that usually happens when the model centre passes into a node, the model centre being the point that determines where light is sampled.
This issue is player model going dark when correctly standing on a node, because the light position is at foot level instead of higher up.

@bigfoot547
Copy link
Contributor

I also noticed that the nametag is not on top of the player, but rather in the center of the player.

@TeTpaAka
Copy link
Contributor

@paramat No, it is the same issues. Now, players, mobs and other entities use the same code for display and so they (should) show the same behavior. If a mob would be standing at the exact same position like the player in your screenshot, it would be black. The client doesn't even differentiate between other players and luaentities.

@bigfoot547 I'll look into it.

@paramat
Copy link
Contributor Author

paramat commented Jul 27, 2017

Ok, i thought people were describing the existing behaviour. Obviously mobs should have the same issue.

@paramat paramat changed the title Player models are dark when below y = 0 GenericCAO models are dark when below y = 0 Jul 28, 2017
@SmallJoker
Copy link
Member

#6179 merged.

@paramat
Copy link
Contributor Author

paramat commented Jul 30, 2017

It wasn't merged, just done it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues that were confirmed to be a bug @ Client / Audiovisuals
Projects
None yet
Development

No branches or pull requests

7 participants