Question: Consider someone who believes in any kind of reincarnation or perfect punishment after death, a theist. That is, all she/he does in this life is done in light of complying with her/his God(s) wishes.

Is it possible for a person like this to be genuinely selfless in the sense of leaving a better world for future generations for their own sake? If so, how?

I don't see what could prevent this hypothetical person from being selfish all his/her life, knowing that the burden will exist only for future generations and not for himself/herself.

\*
\*
\*

NOTE: this is a provocative post, meant to point that this community
moderator deemed this post NOT offensive "[Why should an atheist care about what happens to the world after his/her death?](https://philosophy.stackexchange.com/questions/94177/why-should-an-atheist-care-about-what-happens-to-the-world-after-his-her-death?noredirect=1&lq=1)" but finds offensive to make counterpoints to it.

Answer: 
If we agree on the premise that there's no reason for an atheist to care what happens after their death, then the corollary to that claim is that theists do care about it only because they are **afraid to be punished** in the next life or hell. Which is indeed far from selfless.

If you promise a theist a guaranteed reward or punishment after death (to take out the religion-related self-interest out), they have exactly the same reasons to care for others as atheists. Either you accept that both theists and atheists may have such reasons, or you deny selflessness to both.

In other words, true selflessness is above religion and cannot be substituted by a religious belief.
There are many philosophical positions that tend to promote nihilism, which given human psychology, tends to lead to lack of caring for others.

Many of the critiques of atheism by the religious focus on the way material reductionism removes any value to: values, morality, reason, consciousness, selfhood, and makes any agency, willing or choice irrelevant.

Atheists can make a very similar critique of most monotheism -- if the universe is under the control of an omnipotent and omniscient being, then every thought and action a believer or UNbeliever may take has been pre-planned and scripted by a puppet-master, making any agency or choices we might think we are making -- just self delusion, as well as irrelevant to the future of the universe.

The range of philosophical world-views that can actually support relevant and effective agency and morality -- is actually fairly small. One can find such space within both atheist and theist worldviews.

To get there as an atheist, one can go the Buddhist route, and accept spiritual dualism, but reject theism. OR, one can accept emergence of causal consciousness, and the reality of abstract objects, such as moral principles.

To get there as a theist, one can accept theistic pluralism, such that there is no single puppetmaster. Ditheism is the easiest such route. Massive polytheism will work as well.

Note, your premise is partially valid, as there are more routes to moral relevancy for atheists, and as percentages, more atheists today hold the views that allow moral relevancy than do today's theists.