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

Basic information on TESRs #93

Merged
merged 8 commits into from Apr 10, 2017
Merged

Conversation

elifoster
Copy link
Contributor

This is by no means exhaustive, but it provides a brief introduction to TESRs and explains a few important things (like them using single-instance design).

Adds a new section, "Tile Entities", which should hopefully be expanded.


### `renderTileEntityAt`

This method is called every frame in order to render the tile entity. It passes the instance of the tile entity being renderered, its coordinates as doubles at the origin of the block, partialTicks<!-- I'm not actually sure what this is used for. -->, and the destroy stage of the block if being destroyed.
Copy link
Contributor

Choose a reason for hiding this comment

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

partialTicks is the amount of time, measured in fractions of a tick, that have passed since the last full tick. It's used for interpolating animated/moving things between ticks, so they don't look really jittery.

@diesieben07
Copy link
Contributor

I think you should at least mention FastTESR.

@elifoster
Copy link
Contributor Author

I've never used or looked at any implementations of FastTESR.


#### Parameters
* `tileentity`: This is the instanceof the tile entity being rendered. It uses the generic argument, so, if the class is being inherited correctly, it will not need to be cast to your tile entity class.
* `x`, `y`, `z`: The coordinates of the tile entity as doubles. They are at the origin of the block.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is true, TESR's aren't passed world coords.

In TileEntityRendererDispatcher.renderTileEntity(TileEntity, float, int):

this.renderTileEntityAt(tileentityIn, (double)blockpos.getX() - staticPlayerX, (double)blockpos.getY() - staticPlayerY, (double)blockpos.getZ() - staticPlayerZ, partialTicks, destroyStage);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. You can get the world coords from the te which is probably what I confused myself with when reading my TESRs.

How should I word that then? The position of the tile entity relative to the player's view?

Copy link
Contributor

Choose a reason for hiding this comment

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

"The coordinates at which the TESR should render it's model" or something like that.

@tterrag1098
Copy link
Collaborator

FastTESR should be listed as the preferred way to do a TESR nowadays. Only if you specifically need operations which cannot be done with purely the VertexBuffer, should you use a normal TESR.

@elifoster
Copy link
Contributor Author

Can either of you provide any information on it? I've tried finding some and have been unsuccessful. The most informative thing I've found is the class itself but it doesn't have any documentation so it isn't very useful.

I will list it as the preferred way to do TESRs if someone gives me the actual use case for it vs. the "normal" one and why it is the preferred way to do a TESR. Saying something is preferred without justification doesn't provide enough information/reason to use it over the thing people are already used to, as I described on a different topic at #85, and I'd prefer my PRs avoid doing that 😃

@diesieben07
Copy link
Contributor

I'll write up something this afternoon.

@tterrag1098
Copy link
Collaborator

FastTESR's only advantage is that it s batched with all other FastTESR's. The stipulation of this is that the rendering code must ONLY interact with the VertexBuffer and nothing else (no GL operations). It's really that simple.

@elifoster
Copy link
Contributor Author

Thank you. Diesieben's PR to my fork explained it as well. That is useful to know and is, as far as I know, not possible to find without actually digging into the rendering code.

@elifoster
Copy link
Contributor Author

Any suggestions or anything needed to get this merged?

@tterrag1098 tterrag1098 merged commit a84ad63 into MinecraftForge:master Apr 10, 2017
@elifoster elifoster deleted the tesr branch May 17, 2017 05:15
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.

None yet

5 participants